SAS LANGUAGE

Site owners

  • satish kumar Vatsavai

How to Check for Missing Values in a DATA Step


How to change the Missing value display format?

Options Missing ='*';

When you check for ordinary missing numeric values, you can use code that is similar to the following:

if numvar=. then do;

If your data contains special missing values, you can check for either an ordinary or special missing value with a statement that is similar to the following:

if numvar<=.z then do;

To check for a missing character value, you can use a statement that is similar to the following:

if charvar=' ' then do;

The MISSING function enables you to check for either a character or numeric missing value, as in:

if missing(var) then do;

In each case, SAS checks whether the value of the variable in the current observation satisfies the condition specified. If it does, SAS executes the DO group.

Note:   Missing values have a value of false when you use them with logical operators such as AND or OR.  [cautionend]

Special Missing Values

The result of any numeric missing value in a SAS expression is a period. Thus, both special missing values and ordinary numeric missing values propagate as a period.

data a;
      x=.d;
      y=x+1;
      put y=;
   run;

 

Preventing Propagation of Missing Values (special missing)

 data test;

  x=.;
  y=5;
  a=x+y;
  b=sum(x,y);
  c=5;  
  c+x;
  put a= b= c=;
 run;
Comments