These pages contain SAS programs with a minimum of documentation or explanation. These pages often reflect samples that we have created in solving a problem for someone during consulting. If we do not have time to make a proper FAQ or Learning Module, we place the example program here so it may be publicly available until we have time to make a proper FAQ page or Learning Module page. Until then, we hope that these example may prove useful to some of you. If you are not sure if you are properly using any of these code fragments (and you are a member of the UCLA research community) please use our consulting services so we may help you properly use these examples. Many of these examples are tricky and complicated, so if you are in doubt, please let us assist you.
- Reading/Writing Files
- Making a fixed format file
- Making a SAS Cport file
- Reading a SAS Cport file
- Reading an EBCDIC file
- Reading multiple raw data files, Version 8
- Reading multiple raw data files (version 6.x)
- Using a SAS macro to "set" multiple files
- Reading hierarchical data
- Changing tabs to spaces (if both are included as delimiters)
- Reading an electronic codebook and writing an input statement
- Reading a multiple-line-per-subject data file
- Generating automated filenames
- ANOVA & ANCOVA
- Correlation/Regression
- Getting a partial correlation via regression
- Getting Robust Standard Errors for OLS regression parameters
- Proc SurveyReg examples
- Saving a correlation matrix as a data file
- Getting standardized betas in PROC GLM
- Proc Mixed for Regression over Time
- Logistic regression with a labeled outcome variable
- Analyzing changes in trend over time
- Sobel test of mediated effects
- Heckman selection model
- Zero-inflated Poisson and negative binomial using proc nlmixed
- Logistic, random intercept, and random slope regression models using nlmixed
- Estimation options in nlmixed
- SAS/Graph
- Other
- Correspondence analysis with summary data
- Imputing the median
- Checking for duplicate Ids
- Macro to compute a rolling standard deviation
- Changing the length of a character variable
- Replacing strings
- Concatenating string variables using CAT functions
- Making a custom web page in SAS
- Reading a SAS data file into PROC IML
- Executing system level commands within SAS
- Copying and combining SAS format libraries
- Simple macro to do repeated procs
- Eliminate useless variables
- Matching husbands and wives
- How to compute intraclass correlation
- Creating a wide table from a long dataset using PROC TABULATE
- Merging the NSAF data files
- How can I "fill down" a variable?
- Creating a long list of variable names based on an abbreviated one
- Filling in Missing Values Over Time
- Dummy Coding a Categorical Variable Using a Macro Program
- Matching with a wildcard using Perl regular expression
- A few SAS macro programs for renaming variables dynamically
- Summary table for multiple regression models
- Summary table for logistic regression models
- Reading and Analyzing the Hospital Doctor Patient Dataset