Sas Examples Library:
(SAS is a ocean
and a wonder, and over all, my interest is to get the minimal
set of library that will solve wide collecion of problems in
my work: My discussion is on minimal set of examples)
Programming Logic for SAS:
General principles for programming in SAS (if you are like
me who started programming with FORTRAN (after all FORTRAN is
FORmula TRANslation, not Database translation), you will see
SAS approach is counter intuitive; but SAS is the best way to
read millions of records and with increasing data sizes and
increasing disk sizes, this is a sure success):
- SAS reads one record at a time, moves the alpha-numeric
data elements
into temp registers, does the data step transformations if any,
moves it to program data vector (PDV), and erases the temporary
registers, reads next record, and cycles the process; in the
process, it creates its own formatted data set, called sas
data set and stores them into a subdirectory, identified by
SAS by libname.DataSetName.
- this introduces certain powers and interesting twists
to the
way programming is done in SAS
- there is no limit to reading records and storing it in a
sas data set, as long as there is workable space in the system
- before we start it needs to know from where data needs to
be read (infile - from which file and input - in what format)
-where to write the data output (temp, no need to specify
libname, or specific subdirectory)
-will not know what the previous record contents are at any
particular step, so we have to use retain statement with in
data step, if we want to refer or use the previous record (in
some step, not necessarily the immediately previous record)
-"Do loop"
algorithmic step can not (better said is "need not") work between the records
(because by functional building that is what data step does); only within the
record
-will need to know where to output, if there are
restrictions to output (and hence not to the standard
Libname.SasDatasetName (this also introduces the possibility
of multiple data step dataset names, in the beginning,
especially to output to multiple datasets depending on the
restrictions for output).
In essence we are saying:
Data Step:
-Know where you are reading
from (both directory and filename)
-location and name (raw or
already a sas dataset),
-in what format (the fields) if it is
raw dataset,
-transform -do looping for intra transformation
and statements for inter records, subset the dataset,
-output
the dataset(s).
Macro:
Macros are like sub routines (or stand alone collection of
codes which have input parameters and output parameters),
which could be used as a plug in wherever it could be used
with out affecting the program flow of the main program that
one is doing.
Variations of these are some of the
sas programs I actually
used:
Reading from a large comma delimited txt file generated
from ACCESS:
|