Summary: SAS programming 1: Essentials
1. Essentials
2. Accessing Data
a. Accessing data through libraries
1
3. Exploring and validating data : PROC steps
1. Procedures
Continuous variables: Means, Univariate
Categorical variables: FREQ
2. Filtering rows “where expression…;”
Remark: use of SAS macro variables
3. Formatting values “format var name format.;”
4. Proc Sort
2
4. Preparing data: Data Step
1. Reading data
Remark: use of Format in Data step.
3
2. New variables
- Use of SAS functions
- Numeric functions
- Character functions
- Date functions
4
3. Conditional processing IF…. THEN….. ELSE…..
- In the IF : compound conditions are OK
- In the THEN: only 1 statement
- If you need more statements: use IF…. THEN DO……
5
5. Analyzing and reporting on data : Procedure
- Create titles, footnotes and labels
- Remark: labels in Proc step compared to labels in Data step.
- Categorical variables: Proc FREQ;
- Continuous variables: Proc MEANS; (use of CLASS statement)
6. Exporting results : Data step or Proc step
- To Excel
- Use ODS excel to export reports to multiple worksheets in Excel workbook
Remark: Be sure to close the ODS location at the end of the program! (ODS excel cose;)
6
7. Using SQL in SAS
Create: Create a SAS data set
Select: Select the columns
From: data set (table) from which you read data
Where: Filter rows
ORDER BY: sorting the output
7
Questions
1.
Remark:
1. SAS accepts underscore in the names of variables
2. The problem here is that in the keep statement of the 2nd program, you have to keep
Pressure_Group (with underscore) and not PressureGroup (without underscore).