The examples use CAS tables created directly via DATA steps or 'loadTable' actions to illustrate the functionality without external dependencies.
1 Code Block
PROC CAS Data
Explanation : This example demonstrates the simplest use of the 'tableDetails' action. It first creates a small table named 'simple_data' in the 'casuser' caslib, then uses the action to display summary information about this table, such as the number of rows and columns. By default, the aggregation level is 'SUM' and memory information is included.
Copied!
proc cas;
/* Crée une table simple en mémoire dans la caslib 'casuser' */
data casuser.simple_data;
input id name $;
datalines;
1 Alice
2 Bob
3 Charlie
;
run;
/* Obtient les détails de base pour la table 'simple_data' */
table.tableDetails / name="simple_data";
quit;
1
PROC CAS;
2
/* Crée une table simple en mémoire dans la caslib 'casuser' */
3
DATA casuser.simple_data;
4
INPUT id name $;
5
DATALINES;
6
1 Alice
7
2 Bob
8
3 Charlie
9
;
10
RUN;
11
12
/* Obtient les détails de base pour la table 'simple_data' */
13
TABLE.tableDetails / name="simple_data";
14
QUIT;
2 Code Block
PROC CAS Data
Explanation : This case shows how to use the 'caslib' parameter to target a specific table if it is not in the active caslib. A 'product_info' table is created, and its details are retrieved by specifying 'casuser' as the caslib. It also illustrates the use of the 'table' alias for the 'name' parameter.
Copied!
proc cas;
/* Crée une table 'product_info' dans la caslib 'casuser' */
data casuser.product_info;
input product $ price;
datalines;
Apple 1.00
Banana 0.50
Orange 0.75
Mango 2.20
;
run;
/* Obtient les détails pour 'product_info' en spécifiant explicitement la caslib. */
/* Utilisation de l'alias 'table' pour le paramètre 'name'. */
table.tableDetails /
table="product_info",
caslib="casuser";
quit;
1
PROC CAS;
2
/* Crée une table 'product_info' dans la caslib 'casuser' */
3
DATA casuser.product_info;
4
INPUT product $ price;
5
DATALINES;
6
Apple 1.00
7
Banana 0.50
8
Orange 0.75
9
Mango 2.20
10
;
11
RUN;
12
13
/* Obtient les détails pour 'product_info' en spécifiant explicitement la caslib. */
14
/* Utilisation de l'alias 'table' pour le paramètre 'name'. */
15
TABLE.tableDetails /
16
TABLE="product_info",
17
caslib="casuser";
18
QUIT;
3 Code Block
PROC CAS Data
Explanation : This example uses a larger table ('large_transactions') to illustrate obtaining details at each CAS cluster node level ('level="NODE"'). It also excludes detailed memory usage information ('showMem=FALSE') for a more concise output, which is useful for large distributed tables.
Copied!
proc cas;
/* Crée une table plus grande pour simuler la distribution sur plusieurs nœuds */
data casuser.large_transactions;
do i = 1 to 10000;
region = if mod(i, 4) = 0 then 'North'
else if mod(i, 4) = 1 then 'South'
else if mod(i, 4) = 2 then 'East'
else 'West';
amount = 100 + ranuni(0) * 1000;
output;
end;
run;
/* Obtient les détails par nœud sans inclure les informations mémoire */
table.tableDetails /
name="large_transactions",
caslib="casuser",
level="NODE",
showMem=FALSE;
quit;
1
PROC CAS;
2
/* Crée une table plus grande pour simuler la distribution sur plusieurs nœuds */
3
DATA casuser.large_transactions;
4
DO i = 1 to 10000;
5
region = IF mod(i, 4) = 0 THEN'North'
6
ELSEIF mod(i, 4) = 1THEN'South'
7
ELSEIF mod(i, 4) = 2THEN'East'
8
ELSE'West';
9
amount = 100 + ranuni(0) * 1000;
10
OUTPUT;
11
END;
12
RUN;
13
14
/* Obtient les détails par nœud sans inclure les informations mémoire */
15
TABLE.tableDetails /
16
name="large_transactions",
17
caslib="casuser",
18
level="NODE",
19
showMem=FALSE;
20
QUIT;
4 Code Block
PROC CAS / table.partition Data
Explanation : This advanced example shows how to obtain details for a partitioned table. It creates and partitions a 'raw_sales' table by the 'Region' variable using the 'table.partition' action. Then, it uses 'tableDetails' with 'level="PARTITION"' to display information for each partition. The 'perNode=2' parameter is used to limit the amount of detail reported per node, which is useful for managing output size with highly distributed tables.
Copied!
proc cas;
/* Crée une table avec des données à partitionner */
data casuser.raw_sales;
input Date:yymmdd. Region $ Sales;
format Date yymmdd10.;
datalines;
2023-01-01 North 100
2023-01-01 South 150
2023-01-02 East 120
2023-01-02 West 180
2023-01-03 North 110
2023-01-03 South 160
2023-01-04 East 130
2023-01-04 West 190
2023-01-05 North 200
2023-01-05 South 210
2023-01-06 East 220
2023-01-06 West 230
;
run;
/* Partitionne la table par la variable 'Region' */
table.partition /
name="raw_sales",
caslib="casuser",
groupBy={"Region"},
casOut={name="partitioned_sales_by_region", caslib="casuser", replace=true};
/* Obtient les détails par partition, en limitant la sortie à 2 blocs par nœud */
table.tableDetails /
name="partitioned_sales_by_region",
caslib="casuser",
level="PARTITION",
perNode=2;
quit;
1
PROC CAS;
2
/* Crée une table avec des données à partitionner */
3
DATA casuser.raw_sales;
4
INPUT Date:yymmdd. Region $ Sales;
5
FORMAT Date yymmdd10.;
6
DATALINES;
7
2023-01-01 North 100
8
2023-01-01 South 150
9
2023-01-02 East 120
10
2023-01-02 West 180
11
2023-01-03 North 110
12
2023-01-03 South 160
13
2023-01-04 East 130
14
2023-01-04 West 190
15
2023-01-05 North 200
16
2023-01-05 South 210
17
2023-01-06 East 220
18
2023-01-06 West 230
19
;
20
RUN;
21
22
/* Partitionne la table par la variable 'Region' */
/* Obtient les détails par partition, en limitant la sortie à 2 blocs par nœud */
30
TABLE.tableDetails /
31
name="partitioned_sales_by_region",
32
caslib="casuser",
33
level="PARTITION",
34
perNode=2;
35
QUIT;
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.
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.