Checking for Outliers

A similar program can be used to check for out-of-range numeric values. The SQL statements in Program 8-4 produce a report for heart rate, systolic blood pressure, and diastolic blood pressure readings outside specified ranges. Because missing values are not in the specified ranges, they will be reported as errors by this program.

Program 8-4. Using SQL to Check for Out-of-Range Numeric Values
PROC SQL;
   TITLE "Checking for Out-of-Range Numeric Values";
   SELECT PATNO,
          HR,
          SBP,
          DBP
   FROM CLEAN.PATIENTS
   WHERE HR  NOT BETWEEN 40 AND 100       OR
         SBP NOT BETWEEN 80 AND 200       OR
         DBP NOT BETWEEN 60 AND 120;
QUIT;

The WHERE statement can be written many ways, just as with a WHERE statement in a DATA step. The output from these statements ...

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.