|
|
The topics in this tutorial have been selected to represent some of the most important
tools in SAS for working with complex survey data. The focus is on the SAS data
step language and some of the most basic SAS procedures you need to manipulate data in various ways,
to manage it, and to prepare it for analysis.
Some knowledge of the SAS data step is assumed and can be reviewed
in the first section "Review of the data step and how it works." The
remaining topics--retained variables, BY groups, merging, and
SAS arrays--are presented without assuming prior knowledge of these
concepts. After introducing each concept with the simplest of examples,
applications to real data are given. The section "Miscellaneous Tips
and Tricks" summarizes
useful information on a variety of topics including the two different
SAS work environments (batch
and interactive), SAS options, and the Output Delivery System.
SAS example programs on SAS's tech support site:
Example programs to do data management.
Example of using SAS procedures
Browse the pages for your desired example, and then click the "Full code" tab to see the program.
Other useful resources:
CPC's FAQs on SAS
SAS's online documentation
UNC-CH's introduction to SAS
SAS's Technical Support page
SAS's code samples page
UCLA's stat computing portal
- A simple example
- statements: DATA, INFILE, INPUT, assignment, CARDS, FILENAME, LIBNAME, RUN
- data step logic and default actions
- temporary/permanent SAS data sets
- the Program Data Vector
- executable/non-executable statements
- Keeping only the variables you want
- statements: KEEP, DROP, SET, IF-THEN-ELSE, OUTPUT
- data set options: KEEP=, DROP=
- Keeping only the observations you want
- statements: subsetting IF, DELETE
- What is a retained variable?
- RETAIN statement
- Simple example using a retained variable
- What is a BY-group?
- Real data examples of grouped observations
- FIRST.byvariable and LAST.byvariable
- Program examples using the FIRST.byvariable and LAST.byvariable
- determining the uniqueness of an identifier variable
- creating a household level variable from person level data
- statements: SET, BY, RETAIN, IF-THEN, IF-THEN-ELSE, OUTPUT
- What is a match-merge?
- MERGE statement
- Examples of merging
- The IN= variables
- Program examples using the IN= variables
- What is a SAS array?
- ARRAY statement to declare one and two-dimensional arrays
- Using arrays
- simple examples
- iterative DO
- DIM function
- restructuring a SAS data set
- Batch
- Windowing Environment (aka Display Manager)
- Syntax
- Header style
- Other styles
- LINESIZE & PAGESIZE
- NONUMBER & PAGENO
- NOCENTER, NODATE & SKIP
- MISSING
- Definition
- Accessing data sets
- Version 9 data set
- Version 8 data set
- Version 6 data set
- Transport format
- Merge a single observation data set with a multi-observation data set
-
(insert next tip/trick here)
-
(insert next tip/trick here)
- OBS and FIRSTOBS - system, data set and proc options
- WHERE a condition is true
- Selecting a Random sample
- The _N_ variable
- Traditional output
- Output data set
- HTML-formatted file
Questions or comments? If you are affiliated with the Carolina
Population Center, send them to
Phil Bardsley.
|
|