We've seen three categories of SAS statements --
data mars;
infile "marsPics.data";
input date mmddyy8. ... ;
run;
Note: Avoid extra data steps. Do all calculations, setting formats & labels, etc. in one data step whenever feasible (most of the time). For example --
data a;
infile "a.data";
input x y z;
run;
data b;
set a;
if 0 < x < 6 then x=.;
if 0 < y < 6 then y=.;
if 0 < z < 6 then z=.;
run;
data c;
set b;
score=sum(x,y,z);
run;
Reads and writes the data 3 times -- six passes over the data, total.. The same thing is accomplished by eliminating the extra data steps --
data a;
infile "a.data";
input x y z;
if 0 < x < 6 then x=.;
if 0 < y < 6 then y=.;
if 0 < z < 6 then z=.;
score=sum(x,y,z);
run;
This version reads and writes the data just one time -- two passes over the data. Additonally, version 1 creates 3 temporary data sets: a, b and c; whereas, version 2 creates just one temporary SAS data set: a.
proc contents varnum data=mars; run;
options ls=80 noovp; /* options statement */ libname lhsas "~larryh/sasnotes"; /* libname statement */ filename mars "marsPics.data"; /* filename statement (new) */ %let name=Larryh; /* Macro assignment statement */ title "Mars Summary Data"; /* Title statement */ title2 "Mars Global Surveyor"; /* Title2 statement: Subtitle */ title; title2; /* Clear title and subtitle */
A title statement, for instance, stays "on" until it is changed or canceled, and same for an options statement.
The filename statement is new. It defines an alias for a file -- analogous to the libname statement which defines an alias for a directory. Example:
filename mars "marsPics.data";
data mars;
infile mars;
input date mmddyy8. ... ;
run;
There are two ways to reference a permanent SAS dataset.
Two-part name with a libname statement to define the libref:
libname sasclass ".";
data sasclass.lab3b;
.
.
.
run;
proc print data=sasclass.lab3b
Quoted string containing the UNIX filename of the SAS dataset:
data "lab3b.sas7bdat";
.
.
.
run;
proc print data="lab3b.sas7bdat"
Both of these methods refer to a unix file containing the SAS data set named lab3b.sas7bdat.
strauss.udel.edu% ls -l lab3b.sas7bdat -rw------- 1 traing 1691 16384 Jan 30 11:29 lab3b.sas7bdat strauss.udel.edu%If you use the quoted-string method, be sure the file extension you use is sas7bdat. In both of these examples, the UNIX file resides in the current working directory.