The first example reads raw data from an external CSV file accessible via a URL. The second example generates its own data internally via a DATA step.
1 Code Block
DATA STEP / PROC CASUTIL
Explanation : This code loads a CSV file from a URL into a CAS table. The 'FILENAME' statement defines the URL. The 'DATA step' reads the file, specifying a CAS libref (mycas.names) for the output, indicating that the data is loaded into CAS memory. 'INFILE' handles the CSV format, and 'INPUT' assigns the variables. Finally, 'PROC CASUTIL' is used to permanently save the in-memory CAS table and list it.
Explanation : This example converts a CAS table to a SAS dataset. First, a CAS session is started and a CAS libref (mycas) is created. A first DATA step generates a CAS table named 'mycas.earnings' with calculated data. Then, a libname is defined for a local SAS library ('mySAS'). Finally, a second DATA step reads the CAS table 'mycas.earnings' and saves it as a SAS dataset '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=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=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.
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.