Menu driven version available, but with syntax …
Increased control of analyses
Increased flexibility
Document and recall analyses
Create your own analyses and macros
researchers and analysts should use the syntax-driven SAS-language
You bet:
Excel
SPSS
R
EpiInfo
Stata
SUDAAN
/* -------------*/
* --------------------;
Highlight by left-click dragging your mouse across the syntax
Click the little running icon on the tool bar
Painful Lesson: if you don’t highlight the syntax and just click the running icon, SAS will run every command in the Editor which may result in destroying or re-formatting data sets, etc…
In English, a semicolon is used to link two independent clauses.
In SAS, the semicolon is used to demarcate the end of a syntax statement; SAS likes them very, very, very much.
Most Common Error
RTF for Word documents
“Save as…” or, highlight, R-click
EMF for figures
Export Utilities e.g. for Excel
Help - SAS Help and Documentation - SAS Products - Base SAS - SAS Procedures - Procedures
Help - SAS Help and Documentation - SAS products - Base SAS - SAS Language - Dictionary - Dictionary of Language Elements - SAS Data Set Options
Pointer to existing file on computer
sparcs.mortality
SAS Explorer
‘libname’ in command window
PROC CONTENTS with ALL keyword
proc contents data=sparcs. _all_ nods;
*/*note the space between _all_ and nods*/*
run;
SAS files are created in a DATA step using INPUT
‘dataline’ or ‘cards’ with semicolon on separate line
fixed columns vs. user-specified formats (better)
Tip: look at your data with notepad first…
*INPUT var1 var2 var3 \$ ;*
*INPUT var1 1-5 var2 6-10 var3 $ 16-26 ;*
space-delimited: INPUT list of variable names
numeric is default format, $ indicates a character variable
column input: indicate column start and end positions
INFILE 'F:\\K Data\\SPARCS\\ADR02NY.TXT' LRECl=450 obs=100;
quotation marks e.g. “c:\temp\sparcs.txt”
INPUT
@18 DATE yymmn6.
@44 AGE 3.
@50 COUNTY $CHAR2.
;
*\<\$\>informat_namew.\<d\>*
$ indicates a character variable
informat_name names the informat
w total width of the field to read.
d number of decimal points
‘data dictionary’
variable names, definitions, locations, lengths, informats
often found on download site
may have to request from data vendor or source
*_ERROR_=1 _N_=10*
_ERROR_= binary flag, 1=error, 0=no error
Will also get an indicator of exactly at what column SAS encountered the error, and what the error was
SAS will be kind enough to let you know what it was expecting
ALWAYS CHECK YOUR LOG
missing RUN; next most common
FIRSTOBS = n
PROC IMPORT DATAFILE = ‘filename’ OUT = ‘dataset’; DBMS = identifier REPLACE;