
Quality Control is a very important part of SAS programmer's job. Sometimes we want to find the unexpected values hidden in the data set. Proc Format would be a good way to go.
Suppose we have a lab test data set "eg" here:

We have the range for the variable BASOS, HCT and HGB. If the value goes beyond the range we know, we need to flag it out.
Here is the simple way to do by proc format:
proc format;
value basos
low - 1,
6 - high = 99
other = 1;
value hct
low - 20,
60 - high = 99
other = 1;
value hgb
low - 5,
20 - high = 99
other = 1;
run;
We can either use a new variable diag to flag the unexpected value, or use proc freq.1. The "egDiag":
data egDiag;
set eg;
diag = (max(put(basos, basos.), put(hct, hct.), put(hgb, hgb.)) >= 99);
run;

2. Proc Freq:
proc freq data = eg;
tables basos hct hgb;
format basos basos.
hct hct.
hgb hgb.
;
run;
No comments:
Post a Comment