DATA Step, Macro, Functions and more

Missing Values

Reply
Occasional Contributor
Posts: 6

Missing Values

Please can someone explain if the keyword missover or DSD can be used to label missing values that are not specified in a range? Thanks

Super User
Super User
Posts: 7,392

Re: Missing Values

No, that would be something you put into your code using if then or select statements.

if higher_bound < value then flag="High";

if lower_bount > value then flag="Low";

 

Occasional Contributor
Posts: 6

Re: Missing Values

So what is the keyword thta can be used to label a missing value and values that are not specified in a range.

Super User
Super User
Posts: 7,392

Re: Missing Values

As I said, you would do this with conditional branching:

if higher_bound < value then flag="High";

if lower_bount > value then flag="Low";

 

Valued Guide
Posts: 765

Re: Missing Values

Hi.  Another approach is to write your own INFORMAT to flag values as missing and/or out of an acceptable range as you read the data.  Here's an example using systolic blood pressure.  In case you did not know, there are 28 ways to indicate a mising value ... .A through .Z, plus ._ and the usual way of just a period ... Creating Special Missing Values

 

https://support.sas.com/documentation/cdl/en/lrcon/62955/HTML/default/viewer.htm#a000992455.htm

 


proc format;
invalue sbp
 60-349  = _same_
  1-59   = .L
350-high = .H
   .     = .
;
value sbp
 60-120 = 'NORMAL'
120-139 = Prehypertension
140-159 = 'Hypertension/Stage 1'
160-349 = 'Hypertension/Stage 2'
   .L   = 'Out-of-Range/LOW'
   .H   = 'Out-of-Range/HIGH'
   .    = 'Missing'
;
run;

data x;
infile datalines dsd;
input sbp :sbp. @@;
datalines;
.,30,200,480,100,160,110,130,360,45,,150,152
;

 

proc freq data=x;
tables sbp / missing nocum;
format sbp sbp.;
run;


proc means data=x n nmiss mean maxdec=0;
var sbp;
run;

 

You can see that PROC FREQ will distinguish among the various types of missing values while all of the various missing values are ignored in PROC MEANS ...

 

                 sbp    Frequency     Percent
Missing                        2       15.38
Out-of-Range/HIGH              2       15.38
Out-of-Range/LOW               2       15.38
NORMAL                         2       15.38
Prehypertension                1        7.69
Hypertension/Stage 1           2       15.38
Hypertension/Stage 2           2       15.38

 

 

 Analysis Variable : sbp

         N
 N    Miss            Mean
 7       6             143

Super User
Posts: 10,466

Re: Missing Values

A brief note on SAS lingo: Label is normally used to provide additional text for display of a variable name. Most procedures will display a variable label if assigned. Such as

Label mnwt = 'Mean weight at intake';

So when the variable mnwt is used in proc freq or a modeling procedure the text "Mean weight at intake" will be displayed so people don't have to try to decipher "mnwt".

 

Values of variables display are controlled by Formats to display a desired number of decimal points, currency symbols or to turn code values into full text to name a few bits.

 

There are times when misusing the lingo can lead to responses that do not address your problem.

Ask a Question
Discussion stats
  • 5 replies
  • 194 views
  • 0 likes
  • 4 in conversation