My SAS Programming Tips
- Displaying the contents of the Program Data Vector:
- How I deal with temporary variables: useful naming convention, and drop with a wildcard.
- Parsing character fields: use of
WHERE - Yes, it matters: their effects on
- Forcing printed output in the event of an empty data file: when it is better to see headers and an empty report than to see nothing at all.
- A SAS macro to parse a path into its folder, filename, and extension: and how to read a SAS file given its full path.
- Parsing drug dosages: a use case for the
substr functions: another data wrangling tip.
PROC FORMAT in data munging: it's not just for reporting.
- More on
PROC FORMAT: writing formats to specific libraries; copying formats from one library to another.
- Three SAS Enterprise Guide Options
- Simple dedupe of SAS table based on all columns: using
- Writing text files to the SAS work library: how and why.
- Error message "Insufficient authorization to access C:\WINDOWS\system32\sasgraph.png": How to resolve.
- Scoring regression models:
OUTEST option and
- Scoring regression models: The "Missing Y" method.
- Zero observations imported for .xls file? It opens in Excel but SAS can't read it? How to resolve.
- Dates off by ten years? Dealing with Unix/Posix dates.
- Is this foreign key valid? (1 of 3) Using
PROC FORMAT for data validation.
- Is this foreign key valid? (2 of 3) Using the
MERGE statement and the
- Is this foreign key valid? (3 of 3) Using a hash table.
- A comprehensive example of using hash tables Not one but two hash tables.
- Format blank when zero Also
- Delete rows using
PROC SQL. Beware of this gotcha! (Logical vs. physical delete.)
- Delete rows using
MERGE statement in a
DATA STEP. Also
BY statement and
- Looping with
do over: looping over (through) an array.
OPTION VARINITCHK: show error message (rather than a note) when variables are not initialized.
- Selecting a datetime value into a macro variable, and using that macro variable in a subsequent
- Writing SAS reports to MS Word using
ODS RTF FILE and
ODS RTF CLOSE.
SQLOBS when creating macro variables within
- A simple way to left justify macro variables. (It makes titles look nicer.)
IN in a macro
IF. (It requires
- Two ways to create an empty SAS dataset:
DATA STEP with
PROC SQL with
- A macro to drop a variable from a SAS dataset if that variable exists. My macro
- Encoding passwords with
- Using SAS to FTP an external file. My macro
FTPFILE, because the FTP access engine was corrupting my files.
%INCLUDE a file if it exists.. (Conditionally include a
- Cross tabulations (crosstabs) using
PROC FREQ ). Also
ODS NOPROCTITLE, and
PROC FREQ options
PROC FREQ to conduct a chi-square test of independence. Includes
PROC FREQ to conduct a goodness of fit test. Includes
PROC TTEST to conduct a test of hypothesis about a population mean. Includes
SIDE options, and how to find the confidence interval of a population mean.
PROC FREQ to conduct a test of hypothesis about a population proportion . Also how to find the confidence interval of a population proportion.
- K-means clustering in one dimension using
- Forcing a variable of unknown type to numeric or character. A hack with the