You can get a detailed description of any cas action result set using the describe statement.
proc cas;
/* Get a list of all the tables in the CASUSER caslib */
action table.tableinfo result=r/caslib="casuser";
/* Write a description of the result set to the SAS log */
describe r;
quit;
Produces this information in the SAS log:
dictionary ( 1 entries, 1 used);
[TableInfo] Table ( [2] Rows [24] columns
Column Names:
[1] Name [ ] (varchar)
[2] Label [ ] (varchar)
[3] Rows [ ] (int64)
[4] Columns [ ] (int64)
[5] IndexedColumns [Indexed Columns ] (int64)
[6] Encoding [ ] (char)
[7] CreateTimeFormatted [Created ] (varchar)
[8] ModTimeFormatted [Last Modified ] (varchar)
[9] AccessTimeFormatted [Last Accessed ] (varchar)
[10] JavaCharSet [Character Set ] (char)
[11] CreateTime [ ] (double)
[12] ModTime [ ] (double)
[13] AccessTime [ ] (double)
[14] Global [ ] (int32)
[15] Repeated [ ] (int32)
[16] View [ ] (int32)
[17] MultiPart [ ] (int32)
[18] SourceName [Loaded Source ] (varchar)
[19] SourceCaslib [Source Caslib ] (varchar)
[20] Compressed [ ] (int32)
[21] Creator [Table Creator ] (varchar)
[22] Modifier [Last Table Modifier] (varchar)
[23] SourceModTimeFormatted [Source Modified ] (varchar)
[24] SourceModTime [ ] (double)
So, the result set is a dictionary with a single entry, a table named TableInfo. In the TableInfo table, the NAME column contains the names of the tables in the caslib. We can use this table to drive other CAS actions. For example:
proc cas;
/* Get a list of all the tables in the CASUSER caslib */
action table.tableinfo result=r/caslib="casuser";
/* Using the result set, process every table in a specified caslib */
do i over r.tableinfo;
/* Display detailed table information */
table.tabledetails result=tinfo / caslib="casuser" name=i.name;
print tinfo;
/* Display detailed column information */
table.columninfo result=cinfo / table={caslib="casuser" name=i.name};
print cinfo;
/* Display 5 rows */
table.fetch / table={caslib="casuser" name=i.name} to=5;
end;
quit;
Produces the following results:
tinfo: Results from table.tableDetails
Detail Information for CARS in Caslib CASUSER(SASJedi).
Node
Number of Blocks
Active Blocks
Rows
Data size
Variable Data size
Blocks Mapped
Memory Mapped
Blocks Unmapped
Memory Unmapped
Blocks Allocated
Memory Allocated
Index Size
Compressed Size
Compression Ratio
ALL
40
20
428
68480
0
20
72000
20
72000
0
0
0
0
0
cinfo: Results from table.columnInfo
Column Information for CARS in Caslib CASUSER(SASJedi)
Column
Label
Id
Type
Length
Formatted Length
Format
Format Width
Format Decimal
Make
1
char
13
13
0
0
Model
2
char
40
40
0
0
Type
3
char
8
8
0
0
Origin
4
char
6
6
0
0
DriveTrain
5
char
5
5
0
0
MSRP
6
double
8
8
DOLLAR
8
0
Invoice
7
double
8
8
DOLLAR
8
0
EngineSize
Engine Size (L)
8
double
8
12
0
0
Cylinders
9
double
8
12
0
0
Horsepower
10
double
8
12
0
0
MPG_City
MPG (City)
11
double
8
12
0
0
MPG_Highway
MPG (Highway)
12
double
8
12
0
0
Weight
Weight (LBS)
13
double
8
12
0
0
Wheelbase
Wheelbase (IN)
14
double
8
12
0
0
Length
Length (IN)
15
double
8
12
0
0
Results from table.fetch
Selected Rows from Table CARS
_Index_
Make
Model
Type
Origin
DriveTrain
MSRP
Invoice
Engine Size (L)
Cylinders
Horsepower
MPG (City)
MPG (Highway)
Weight (LBS)
Wheelbase (IN)
Length (IN)
1
Acura
MDX
SUV
Asia
All
$36,945
$33,337
3.5
6
265
17
23
4451
106
189
2
Audi
RS 6 4dr
Sports
Europe
Front
$84,600
$76,417
4.2
8
450
15
22
4024
109
191
3
BMW
745Li 4dr
Sedan
Europe
Rear
$73,195
$66,830
4.4
8
325
18
26
4464
123
204
4
Cadillac
Seville SLS 4dr
Sedan
USA
Front
$47,955
$43,841
4.6
8
275
18
26
3992
112
201
5
Chevrolet
Astro
Sedan
USA
All
$26,395
$23,954
4.3
6
190
14
17
4605
111
190
tinfo: Results from table.tableDetails
Detail Information for IRIS in Caslib CASUSER(SASJedi).
Node
Number of Blocks
Active Blocks
Rows
Data size
Variable Data size
Blocks Mapped
Memory Mapped
Blocks Unmapped
Memory Unmapped
Blocks Allocated
Memory Allocated
Index Size
Compressed Size
Compression Ratio
ALL
40
20
150
7200
0
20
10720
20
10720
0
0
0
0
0
cinfo: Results from table.columnInfo
Column Information for IRIS in Caslib CASUSER(SASJedi)
Column
Label
Id
Type
Length
Formatted Length
Format Width
Format Decimal
Species
Iris Species
1
char
10
10
0
0
SepalLength
Sepal Length (mm)
2
double
8
12
0
0
SepalWidth
Sepal Width (mm)
3
double
8
12
0
0
PetalLength
Petal Length (mm)
4
double
8
12
0
0
PetalWidth
Petal Width (mm)
5
double
8
12
0
0
Results from table.fetch
Selected Rows from Table IRIS
_Index_
Iris Species
Sepal Length (mm)
Sepal Width (mm)
Petal Length (mm)
Petal Width (mm)
1
Setosa
50
33
14
2
2
Setosa
49
30
14
2
3
Setosa
51
35
14
3
4
Versicolor
61
28
40
13
5
Versicolor
58
27
39
12
You didn't specify how you wanted to save the tables - as files in the CASLIB (and what type - SASHDAT, CSV, etc) or as SAS data sets, so I have no sample code for that. But these same techniques should be able to be adapted for use with the table.save CAS action of the SAVERESULT statement to achieve your desired result.
Hope this helps. May the SAS be with you!
... View more