Macros Based on the Two Methods of Outlier Detection

It is straightforward to turn each of the above programs into more general purpose macros. First, here is a macro that detects outliers based on a standard deviation computed from all the data.

Program 2-21. Creating a Macro to Detect Outliers Based on a Standard Deviation
*------------------------------------------------------------------* | Program Name: SD_ALL.SAS in C:\CLEANING | | Purpose: To identify outliers based on n standard deviations | | from the mean. | | Arguments: DSN - Data set name | | VAR - Numeric variable to be checked | | IDVAR - ID variable name | | N_SD - The number of standard deviation units for | | declaring an outlier | | | | Example: %SD_ALL(CLEAN.PATIENTS,HR,PATNO,2) ...

Get Cody’s Data Cleaning Techniques Using SAS® Software now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.