The examples use generated data (datalines) to ensure their autonomy. The 'cholesterol' table is created and loaded into CAS memory for the save demonstrations.
1 Code Block
DATA STEP / PROC CAS Data
Explanation : This example creates a simple SAS table using a DATA step with DATALINES, loads it into CAS memory, and then saves it as a SAS7BDAT file in the 'casuser' caslib without any encryption options. The 'fileinfo' command verifies that the file was created successfully.
Copied!
data work.cholesterol;
input Name $ Age Sex $ Cholesterol_Level;
datalines;
John_Doe 45 M 200
Jane_Smith 30 F 180
Peter_Jones 55 M 240
Alice_Brown 25 F 160
;
run;
cas casauto sessopts=(caslib="casuser");
proc cas;
table.upload /
caslib="casuser",
path="cholesterol",
casout={name="cholesterol", replace=true};
table.save /
table="cholesterol",
name="cholesterol_basic.sas7bdat",
exportOptions={fileType="basesas"},
replace=true;
quit;
proc cas;
table.fileinfo / caslib="casuser" pattern="cholesterol_basic.sas7bdat";
quit;
Explanation : This case reproduces the example from the documentation. It creates the 'cholesterol' table, loads it into CAS memory, and then saves it as an AES2 encrypted SAS7BDAT file with a specified password. The 'fileinfo' command verifies that the file was created successfully.
Copied!
data work.cholesterol;
input Name $ Age Sex $ Cholesterol_Level;
datalines;
John_Doe 45 M 200
Jane_Smith 30 F 180
Peter_Jones 55 M 240
Alice_Brown 25 F 160
;
run;
cas casauto sessopts=(caslib="casuser");
proc cas;
table.upload /
caslib="casuser",
path="cholesterol",
casout={name="cholesterol", replace=true};
table.save /
table="cholesterol",
name="cholesterol_encr.sas7bdat",
exportOptions={
fileType="basesas",
encrypt="AES2",
encryptionPassword="pasquotank"
},
replace=true;
quit;
proc cas;
table.fileinfo / caslib="casuser" pattern="cholesterol_encr.sas7bdat";
quit;
Explanation : This example illustrates a more advanced usage by saving a subset of data (here, records where Cholesterol_Level is greater than 200) to a different format, namely CSV. The 'where' parameter is used for filtering and 'exportOptions={fileType="csv"}' for the output format. The 'fileinfo' command verifies that the file was created successfully.
Copied!
data work.cholesterol;
input Name $ Age Sex $ Cholesterol_Level;
datalines;
John_Doe 45 M 200
Jane_Smith 30 F 180
Peter_Jones 55 M 240
Alice_Brown 25 F 160
;
run;
cas casauto sessopts=(caslib="casuser");
proc cas;
table.upload /
caslib="casuser",
path="cholesterol",
casout={name="cholesterol", replace=true};
table.save /
table="cholesterol",
where="Cholesterol_Level > 200",
name="cholesterol_filtered.csv",
exportOptions={fileType="csv"},
replace=true;
quit;
proc cas;
table.fileinfo / caslib="casuser" pattern="cholesterol_filtered.csv";
quit;
Explanation : This example shows how to create a temporary caslib ('my_temp_caslib') and save the 'cholesterol' table to it. This is useful for managing data between different CAS storage spaces or for preparing data for external use outside the original caslib. The temporary caslib is deleted at the end of execution for cleanup. The 'fileinfo' command verifies that the file was created successfully.
Copied!
data work.cholesterol;
input Name $ Age Sex $ Cholesterol_Level;
datalines;
John_Doe 45 M 200
Jane_Smith 30 F 180
Peter_Jones 55 M 240
Alice_Brown 25 F 160
;
run;
cas casauto sessopts=(caslib="casuser");
proc cas;
table.upload /
caslib="casuser",
path="cholesterol",
casout={name="cholesterol", replace=true};
caslib.add /
caslib="my_temp_caslib",
path="/tmp/my_temp_data",
subdirs=true,
global=false,
dataSource={srcType="path"};
table.save /
table="cholesterol",
caslib="my_temp_caslib", /* Spécifie la caslib de destination */
name="cholesterol_remote.sas7bdat",
exportOptions={fileType="basesas"},
replace=true;
quit;
proc cas;
table.fileinfo / caslib="my_temp_caslib" pattern="cholesterol_remote.sas7bdat";
caslib.drop / caslib="my_temp_caslib" quiet=true;
quit;
1
DATA work.cholesterol;
2
INPUT Name $ Age Sex $ Cholesterol_Level;
3
DATALINES;
4
John_Doe 45 M 200
5
Jane_Smith 30 F 180
6
Peter_Jones 55 M 240
7
Alice_Brown 25 F 160
8
;
9
RUN;
10
11
cas casauto sessopts=(caslib="casuser");
12
13
PROC CAS;
14
TABLE.upload /
15
caslib="casuser",
16
path="cholesterol",
17
casout={name="cholesterol", replace=true};
18
19
caslib.add /
20
caslib="my_temp_caslib",
21
path="/tmp/my_temp_data",
22
subdirs=true,
23
global=false,
24
dataSource={srcType="path"};
25
26
TABLE.save /
27
TABLE="cholesterol",
28
caslib="my_temp_caslib", /* Spécifie la caslib de destination */
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.
« If you are saving very large tables, be aware that .sas7bdat is a single-threaded format. For massive datasets, saving as a partitioned .sashdat or a .parquet file will offer significantly better performance for future CAS loads »
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.