INTRODUCTION TO SAS PROGRAMMING


 Overview of SAS Products
Base SAS - data management and basic procedures • SAS/STAT - statistical analysis • SAS/GRAPH - presentation quality graphics • SAS/OR - Operations research • SAS/ETS - Econometrics and Time Series Analysis • SAS/IML - interactive matrix language • SAS/AF - applications facility (menus and interfaces) • SAS/QC - quality control There are other specialized products for spreadsheets, access to databases, connectivity between different machines running SAS

Basic Structure of SAS
 There are two main components to most SAS programs - the data step(s) and the procedure step(s). The data step reads data from external sources, manipulates and combines it with other data set and prints reports. The data step is used to prepare your data for use by one of the procedures (often called “procs”). SAS is very lenient about the format of its input - statements can be broken up across lines, multiple statements can appear on a single line, and blank spaces and lines can be added to make the program more readable.

Structure of SAS programs
 • Lines beginning with an asterisk (*) are treated as comments. Alternatively you can enclose comments between /* and */. • You can combine as many data and proc steps in whatever order you want. • Data steps begin with the word data and procedure steps begin with the word proc. • The run; command signals to SAS that the previous commands can be executed. • Terminate an interactive SAS job with the endsas; statement. • There are global options (like linesize and pagesize) as well as options specific to datasets and procedures.


FTP Access
SAS provides the ability to read data directly from an FTP server, without the need to create a local copy of the file, through the ftp keyword of the filename statement. Suppose there is a data file called user.dat in the directory public on an ftp server named ftp.myserver.com. If your user name is joe and your password is secret, the following statement will establish a fileref for reading the data: filename myftp ftp ’user.dat’ cd=’/public’ user=’joe’ pass=’secret’ host=’ftp.myserver.com’;

Reading SAS programs from external files

 The infile statement can be used to read data which is stored in a file separate from your SAS program. When you want SAS to read your program from an external file you can use the %include statement, followed by a filename or fileref. After SAS processes a %include statement, it continues to read data from its original source (input file, keyboard or display manager 


Comments

Post a Comment

Popular posts from this blog

The 5 Most Common Digital Marketing Strategies

Seven Awesome Things You Can Learn From Sas

What are Hadoop alternatives and should you look for one?