SAS/Basics
From Wikibooks, the open-content textbooks collection
< SAS
Contents |
[edit] Why use SAS ?
- SAS works directly on the database without loading it into memory. This allows you to manipulate large database such as census data.
[edit] Alternative to SAS
- R : an open source statistical package
- Stata : includes the very latest econometric methods
- SPSS : an easy to use statistical software
[edit] SAS Environment
- EDITOR (F5)
- This is a text editor with syntax highlighting where you write your program. You can save your programme with the .sas extension.
- LOG (F6)
- includes all informations about the computing process such as errors, warnings, computing time (cpu). You can save it with the .log extension.
- OUTPUT (F7)
- This includes all the results. You can save it with the .lst extension.
- EXPLORER (CTRL +D)
- browse all your SAS libraries and open datasets in the SAS data editor.
- HELP (F1)
- Help system.
[edit] SAS Programming Style
- SAS includes procedures and data step. data steps generally create a new dataset and procedure step compute some quantity of interest using existing data.
- Each step is ended with the run ; statement.
- Semicolons ; are end of line delimiter.
- SAS works directly on the database without loading it into memory. This allows you to manipulate large database.
- F3 executes the current program or the selected lines of the program.
- After executing a program, you first look at your log and then you can have a look at your results.
- Comments begins with an are or are included between a slash and a star and a star and a slash :
* This is a comment ;
/*This is also a comment */
- SAS is not case sensitive ("a" and "A" are similar to SAS)
[edit] Preamble
The following lines are often useful at the beginning of a SAS program :
- Libname : It is often useful to defines libname. A libname is nothing more than an alias for a directory.
libname lib_name 'c:/data/ee';
- Options : the following line in head of a program makes it easier to read the log.
options errors=1 noovp pageno=1 ls=78;
- Clean log and output windows : At the beginning of a program it is often convenient to clean the log and the output:
dm "CLEAR LOG ; CLEAR OUTPUT ; " ;
dm stands for "Display Manager"