This is a draft cheat sheet. It is a work in progress and is not finished yet.
Preliminaries
*Free Software for Learning
Get your data into a DataFrame
Load a DataFrame from a CSV file
proc import datafile="C:\file.csv"
out=outdata
dbms=csv
replace;
getnames=yes;
run; |
Note: often works. Refer to SAS docs for all arguments
From inline csv text to a DataFrame
data names;
infile datalines delimiter=',';
input first $ last $;
datalines;
Ali,Ajouz
Karam,Ghawi
; |
Note: The DATALINES statement does not provide input options for reading data. However, you can access some options by using the DATALINES statement in conjunction with an INFILE statement.
Saving DataFrame to csv file
proc export data=sashelp.HEART
outfile="/folders/myfolders/file.csv"
dbms=csv
replace;
run; |
Note: often works. Refer to SAS docs for all arguments
Saving DataFrame to Excel Workbook
proc export data=sashelp.class
outfile="/folders/myfolders/file.xlsx"
dbms=XLSX
replace;
run; |
Note: often works. Refer to SAS docs for all arguments
|
|
Working with the whole DataFrame
Peek at the DataFrame contents
/* Data set attributes + columns list */
proc datasets ;
contents data=SASHELP.HEART order=collate;
quit;
/* Data Header (first 5 rows) */
proc print data=sashelp.class (obs=5);
run;
/* Data Footer (last 5 rows) */
%let obswant=5;
data want;
set sashelp.class nobs=obscount;
if _n_ gt (obscount-&obswant.);
run;
proc print data=want;
run; |
|