Statistical software SAS
Basic SAS programming
a online material to learn basic data handling and manipulation in SAS
Read data from the SAS editor, the complete program (a .sas file, you need SAS to open it).
Example data
Water (continous data). Dataset water.xlsx or use read_water_data.sas, a SAS program to read the data.
Jobdata (categorical data). Dataset jobdata.xlsx or use read_jobdata.sas, a SAS program to read the data.
Frequently asked questions:
How to use SAS import in SAS 9.4. (Error message: Connection failed).
Logistic regression:
In PROC LOGISTIC why aren't the coefficients consistent with the odds ratios?
Typical errors in SAS programming
Missing semicolons
The most typical error in SAS programming is to miss out on a semicolon in the end of the line. An error is given, but for SAS it is difficult to identify the problem as a missing semicolon. Below the error is indicated as the run; line. The error is in the line above. Run could then not be identified.
308 data indata1a;
309 set indata1;
310 if concent>25
311 run;
---
22
ERROR 22-322: Syntax error, expecting one of the following: !, !!, &, *, **, +, -, /, <, <=, <>, =, >, ><, >=, AND, EQ, GE, GT, IN, LE,
LT, MAX, MIN, NE, NG, NL, NOTIN, OR, ^=, |, ||, ~=.
Creating new data sets
Another typical error when making subsets or creating new variables in a data set is that either one of the names is misspelled or a condition is not fullfilled. In the log-window you see that the newly created data set indata1a has 0 observations. Observe that this is only given as a note not as error or warning.
A condition is not fullfilled:
NOTE: There were 48 observations read from the data set WORK.INDATA1.
NOTE: The data set WORK.INDATA1A has 0 observations and 3 variables.
The variable is misspelled:
NOTE: Variable concentr is uninitialized.
NOTE: There were 48 observations read from the data set WORK.INDATA1.
NOTE: The data set WORK.INDATA1A has 0 observations and 4 variables.