Thursday, August 21, 2008

How to use the MISSING function when you don't know if the variable is characer or numeric

Using the MISSING function from SAS Functions by Example By Ron Cody

Ever need to check for a missing value, but you're not sure if the variable is character or numeric? No problem when you use the MISSING function. This function takes either character or numeric variables and it checks for the .A, .B, ._ numeric missing values as well.

For example:

DATA MISSING;
INPUT CHAR $ X Y;
IF MISSING(CHAR) THEN N_CHAR + 1;
IF MISSING(X) THEN N_X + 1;
IF MISSING(Y) THEN N_Y + 1;
DATALINES;
CODY 5 6
. . .
WHATLEY .A ._
LAST 10 20
;


PROC PRINT DATA=MISSING NOOBS;
TITLE "Listing of MISSING";
RUN;
A listing of MISSING, below, shows that the MISSING function works correctly with character and numeric values, including all the alternative numeric missing values:

Listing of MISSING


source: www.support.sas.com

0 comments:

Post a Comment

ShareThis