The first example reads a CSV file from an external URL provided in the example, and the second example generates data internally using a DATA step.
1 Code Block
DATA STEP / PROC CASUTIL Data
Explanation : In SAS, load the external comma-separated file using the INFILE statement. Specify a CAS engine libref for the output table. The TRUNCOVER option allows SAS to correctly read variable-length records. Variables without assigned values are set to missing. Specify the INPUT statement to list column names and read them as informats. Save a permanent copy of the in-memory CAS table.
Explanation : Start a CAS session named Casauto and specify the personal caslib, Casuser, as the active caslib. Use the CAS LIBNAME statement to create a CAS engine libref. Create a CAS table named mycas.earnings to use for the example. Create a libref named mySAS to store the table as a SAS dataset. The libref mySAS represents the physical location where the dataset is stored. Read the mycas.earnings table and write it as a SAS dataset named mySAS.earnings.
Copied!
cas casauto sessopts=(caslib='casuser');
libname mycas cas;
caslib _all_ assign;
data mycas.earnings;
Amount=1000;
Rate=.075/12;
do month=1 to 12;
Earned +(amount+earned)*(rate);
end;
run;
proc print data=mycas.earnings;
run;
libname mySAS "u/user/myfiles/";
data mySAS.earnings;
set mycas.earnings;
run;
1
cas casauto sessopts=(caslib='casuser');
2
LIBNAME mycas cas;
3
caslib _all_ assign;
4
5
DATA mycas.earnings;
6
Amount=1000;
7
Rate=.075/12;
8
DO month=1 to 12;
9
Earned +(amount+earned)*(rate);
10
END;
11
RUN;
12
PROC PRINTDATA=mycas.earnings;
13
RUN;
14
15
LIBNAME mySAS "u/user/myfiles/";
16
17
DATA mySAS.earnings;
18
SET mycas.earnings;
19
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.
« Navigating between the SAS Compute Server (traditional SAS) and the CAS Server (Cloud Analytic Services) requires a clear understanding of where your data "lives" and how it moves. The true power of SAS Viya lies in the ability to bridge these two environments seamlessly, but efficiency depends on how you handle memory and threading.
To verify where your DATA step is executing, check the SAS Log for the message: "The SAS System stopped processing this step because of errors" (which may indicate a CAS-incompatible function) or look for notes regarding "Running in CAS". If you don't see CAS-specific notes, your data is being pulled back to the local Compute Server, which can drastically slow down processing on large datasets. »
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.