Published on :
Général CREATION_INTERNE

Sans titre

This code is also available in: Español Français
Awaiting validation
Data Analysis

Type : CREATION_INTERNE


Examples use generated data (datalines) or SASHELP.

1 Code Block
DATA STEP / PROC CAS Data
Copied!
1cas;
2/* Créer une table temporaire en mémoire CAS */
3DATA casuser.ma_table_basique;
4 INPUT ID Name $ Value;
5 DATALINES;
61 Alice 100
72 Bob 150
83 Charlie 120
9;
10RUN;
11 
12/* Afficher les informations de la table */
13PROC CAS;
14 TABLE.tableInfo RESULT=r / name="ma_table_basique" caslib="casuser";
15 PRINT r;
16RUN;
2 Code Block
DATA STEP / PROC CAS Data
Copied!
1cas;
2/* Créer une table dans le caslib "Samples" */
3DATA samples.produits_ventes;
4 INPUT Annee Produit $ Quantite Prix;
5 DATALINES;
62023 A 10 100
72023 B 20 50
82024 A 15 110
92024 C 5 200
10;
11RUN;
12 
13/* Tenter d'obtenir des informations sur une table inexistante, en mode silencieux */
14PROC CAS;
15 TABLE.tableInfo RESULT=r_non_existent / name="table_introuvable" quiet=TRUE;
16 PRINT r_non_existent;
17RUN;
18 
19/* Obtenir des informations sur une table existante dans un caslib spécifique */
20PROC CAS;
21 TABLE.tableInfo RESULT=r_existent / name="produits_ventes" caslib="Samples";
22 PRINT r_existent;
23RUN;
3 Code Block
DATA STEP / PROC CAS Data
Copied!
1cas;
2/* Créer quelques tables avec des noms contenant des caractères spéciaux */
3DATA casuser.donnees_2023_Q1; ID=1; Val=10; RUN;
4DATA casuser.donnees_2023_Q2; ID=2; Val=20; RUN;
5DATA casuser.donnees_2024_Q1; ID=3; Val=30; RUN;
6DATA casuser.rapport_final; ID=4; Val=40; RUN;
7 
8/* Rechercher toutes les tables dont le nom commence par "donnees_" et contient "2023",
9 en utilisant le caractère joker '%' et en désactivant wildIgnore pour qu'il soit interprété */
10PROC CAS;
11 TABLE.tableInfo RESULT=r_wildcard /
12 name="donnees_2023_%"
13 caslib="casuser"
14 wildIgnore=FALSE;
15 PRINT r_wildcard;
16RUN;
4 Code Block
DATA STEP / PROC CAS Data
Copied!
1cas;
2/* Créer une table dont le nom contient un caractère spécial à échapper */
3DATA casuser."resultat_final_%_test";
4 ID=10;
5 Score=95.5;
6RUN;
7 
8/* Tenter de trouver la table en utilisant un joker pour le nom et un caractère d'échappement */
9PROC CAS;
10 TABLE.tableInfo RESULT=r_escape /
11 name="resultat_final_\%_test" /* Cherche le '%' littéral */
12 caslib="casuser"
13 wildIgnore=FALSE /* Active l'interprétation des jokers */
14 wildEscape="\\"; /* Indique que '\' est le caractère d'échappement */
15 PRINT r_escape;
16RUN;
17 
18/* Autre exemple : Lister toutes les tables dans casuser */
19PROC CAS;
20 TABLE.tableInfo RESULT=r_all /
21 name="%"
22 caslib="casuser"
23 wildIgnore=FALSE;
24 PRINT r_all;
25RUN;
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.
Copyright Info : Copyright © SAS Institute Inc. All Rights Reserved