Examples use generated data (datalines) or tables created via DATA steps in CAS memory.
1 Code Block
PROC TEXTMINE Data
Explanation : This example shows basic tokenization of a small collection of textual documents. It creates an in-memory CAS table and applies the TEXTMINE procedure to extract terms by default.
Copied!
CAS;
libname mycas cas;
data mycas.docs;
infile datalines dlm='|';
input doc_id $ text $100.;
datalines;
1|Ceci est un document sur l'analyse de texte.
2|L'analyse de texte est très utile pour l'exploration de données.
3|SAS Viya offre de puissants outils d'analyse de données.
;
run;
proc textmine data=mycas.docs;
id doc_id;
text text;
run;
quit;
1
CAS;
2
LIBNAME mycas cas;
3
4
DATA mycas.docs;
5
INFILEDATALINES dlm='|';
6
INPUT doc_id $ text $100.;
7
DATALINES;
8
1|Ceci est un document sur l'analyse de texte.
9
2|L'analyse de texte est très utile pour l'exploration de données.
10
3|SAS Viya offre de puissants outils d'analyse de données.
11
;
12
RUN;
13
14
PROC TEXTMINEDATA=mycas.docs;
15
id doc_id;
16
text text;
17
RUN;
18
QUIT;
2 Code Block
PROC TEXTMINE Data
Explanation : This example illustrates the use of common TEXTMINE procedure options. It filters stop words to ignore irrelevant words and applies stemming to reduce words to their base form, which is useful for grouping terms and facilitating theme analysis.
Copied!
CAS;
libname mycas cas;
data mycas.docs_inter;
infile datalines dlm='|';
input doc_id $ text $200.;
datalines;
1|Les données massives sont importantes pour l'apprentissage automatique et l'analyse prédictive.
2|L'apprentissage automatique et l'intelligence artificielle révolutionnent le traitement des données.
3|Le traitement des données est un domaine clé de l'analyse statistique et de l'intelligence artificielle.
;
run;
proc textmine data=mycas.docs_inter;
id doc_id;
text text;
stoplist / default; /* Utilise une liste de mots vides par défaut */
stemming; /* Applique la racinisation */
run;
quit;
1
CAS;
2
LIBNAME mycas cas;
3
4
DATA mycas.docs_inter;
5
INFILEDATALINES dlm='|';
6
INPUT doc_id $ text $200.;
7
DATALINES;
8
1|Les données massives sont importantes pour l'apprentissage automatique et l'analyse prédictive.
9
2|L'apprentissage automatique et l'intelligence artificielle révolutionnent le traitement des données.
10
3|Le traitement des données est un domaine clé de l'analyse statistique et de l'intelligence artificielle.
11
;
12
RUN;
13
14
PROC TEXTMINEDATA=mycas.docs_inter;
15
id doc_id;
16
text text;
17
stoplist / default; /* Utilise une liste de mots vides par défaut */
18
stemming; /* Applique la racinisation */
19
RUN;
20
QUIT;
3 Code Block
PROC TEXTMINE Data
Explanation : This advanced example demonstrates the extraction of n-grams (sequences of words like 'artificial intelligence' or 'machine learning'). The OUTNGRAM option generates a table of n-grams, allowing for the capture of more complex semantic relationships than single words. Note that the TEXTMINE procedure focuses on the extraction of terms and n-grams; more sophisticated named entity extraction would require more specific text mining CAS actions or other SAS Text Analytics modules.
Copied!
CAS;
libname mycas cas;
data mycas.docs_adv;
infile datalines dlm='|';
input doc_id $ text $200.;
datalines;
1|La conférence SAS Global Forum 2024 a présenté des innovations en intelligence artificielle.
2|Dr. John Smith, expert en machine learning, a donné une présentation clé sur l'analyse de sentiments.
3|Le siège social de SAS est à Cary, en Caroline du Nord, USA.
;
run;
proc textmine data=mycas.docs_adv;
id doc_id;
text text;
outngram out=mycas.ngrams;
run;
quit;
proc print data=mycas.ngrams;
title "N-grammes extraits";
run;
1
CAS;
2
LIBNAME mycas cas;
3
4
DATA mycas.docs_adv;
5
INFILEDATALINES dlm='|';
6
INPUT doc_id $ text $200.;
7
DATALINES;
8
1|La conférence SAS Global Forum 2024 a présenté des innovations en intelligence artificielle.
9
2|Dr. John Smith, expert en machine learning, a donné une présentation clé sur l'analyse de sentiments.
10
3|Le siège social de SAS est à Cary, en Caroline du Nord, USA.
11
;
12
run;
13
14
proc textmine data=mycas.docs_adv;
15
id doc_id;
16
text text;
17
outngram out=mycas.ngrams;
18
run;
19
quit;
20
21
proc print data=mycas.ngrams;
22
title "N-grammes extraits";
23
RUN;
4 Code Block
CAS Action (textmining.sastoken) Data
Explanation : This example illustrates a more direct approach to text mining in the SAS Viya environment by using the CAS `sastoken` action. This action is one of the fundamental components that the TEXTMINE procedure uses behind the scenes. It enables efficient tokenization and normalization of textual data directly on the CAS server, demonstrating the power of distributed processing for large volumes of textual data.
Copied!
CAS;
/* Création d'une session CAS */
cas sess;
/* Chargement des données dans CAS */
data mycas.cas_data;
infile datalines dlm='|';
input doc_id $ text $100.;
datalines;
1|Le traitement du langage naturel est une branche de l'intelligence artificielle.
2|L'IA et le machine learning transforment l'industrie de la technologie.
3|SAS Viya est une plateforme d'analyse unifiée pour les données et l'IA.
;
run;
/* Utilisation de l'action CAS 'sastoken' pour la tokenisation */
proc cas;
textmining.sastoken /
caslib='mycas'
textinput={
caslib='mycas',
name='cas_data',
id={'doc_id'},
text={'text'}
}
casout={
caslib='mycas',
name='tokens_cas',
replace=TRUE
};
run;
quit;
/* Afficher les tokens générés par l'action CAS */
proc print data=mycas.tokens_cas;
title "Tokens générés par l'action CAS sastoken";
run;
1
CAS;
2
/* Création d'une session CAS */
3
cas sess;
4
5
/* Chargement des données dans CAS */
6
DATA mycas.cas_data;
7
INFILEDATALINES dlm='|';
8
INPUT doc_id $ text $100.;
9
DATALINES;
10
1|Le traitement du langage naturel est une branche de l'intelligence artificielle.
11
2|L'IA et le machine learning transforment l'industrie de la technologie.
12
3|SAS Viya est une plateforme d'analyse unifiée pour les données et l'IA.
13
;
14
run;
15
16
/* Utilisation de l'ACTION CAS 'sastoken' pour la tokenisation */
17
PROC CAS;
18
textmining.sastoken /
19
caslib='mycas'
20
textinput={
21
caslib='mycas',
22
name='cas_data',
23
id={'doc_id'},
24
text={'text'}
25
}
26
casout={
27
caslib='mycas',
28
name='tokens_cas',
29
replace=TRUE
30
};
31
RUN;
32
QUIT;
33
34
/* Afficher les tokens générés par l'action CAS */
35
PROC PRINTDATA=mycas.tokens_cas;
36
title "Tokens générés par l'ACTION CAS sastoken";
37
RUN;
This material is provided "as is" by We Are Cas. There are no warranties, expressed or implied, as to merchantability or fitness for a particular purpose regarding the materials or code contained herein. We Are Cas is not responsible for errors in this material as it now exists or will exist, nor does We Are Cas provide technical support for it.
« In the world of SAS Viya, PROC TEXTMINE is the cornerstone of unstructured data processing. Unlike traditional text parsing, this procedure leverages the distributed, in-memory architecture of Cloud Analytic Services (CAS) to transform raw text into mathematical representations at massive scale. By converting sentences into numerical vectors, it bridges the gap between human language and machine learning. »
SAS and all other SAS Institute Inc. product or service names are registered trademarks or trademarks of SAS Institute Inc. in the USA and other countries. ® indicates USA registration. WeAreCAS is an independent community site and is not affiliated with SAS Institute Inc.
This site uses technical and analytical cookies to improve your experience.
Read more.