Posted by : Netbloggy Saturday, September 19, 2015

Sometimes it's just easier to use in-built SAS functions while processing the data rather than writing many complex statements in the DATA step. This is a simple peek into some of the numeric functions of SAS.

Problem:

Count the number of missing values for WBC, RBC, and Chol in the Blood data set.
Use the MISSING function to detect missing values.

Solution:

 
data A15001.A01_MissingVals;
 set A15001.A01_Blood;
 if missing(WBC) then Miss_WBC + 1; /* missing() to detect missing and + sum function to increment */
 if missing(RBC) then Miss_RBC + 1;
 if missing(Chol) then Miss_Chol + 1;
run;
 
proc print data=A15001.A01_MissingVals noobs; run;


Output:


Learning:

How to use Missing() function to processing numeric data with missing values

Problem:

Create a new, temporary SAS data set (Miss_Blood) based on the SAS data set
Blood. Set Gender, RBC, and Chol to a missing value if WBC is missing. Use the
MISSING and CALL MISSING functions in this program.

Solution:

data A15001.A01_Miss_Blood;
 set A15001.A01_Blood;
 if missing(WBC) then CALL Missing(of Gender RBC Chol);
run;
 
proc print data=A15001.A01_Miss_Blood; run;

Output:

Learning: 

How to use CALL Routine with Missing function

Download the code here

Leave a Reply

Subscribe to Posts | Subscribe to Comments

Popular Post

Blogger templates

Total Pageviews

Powered by Blogger.

- Copyright © nulldata -Metrominimalist- Powered by Blogger - Designed by Johanes Djogan -