Help using Base SAS procedures

Loop and validate each variables

Not applicable
Posts: 0

Loop and validate each variables

I'm a beginner in SAS, and have been exposed to SAS for less than a week only. I need helps from you guys in solving this problem, for which I have to deliver the solution by tomorrow.

I have a data set with, let say 500 variables. I need to produce a list of records of which any one of the 500 variables containing null value. How can I do this with SAS?

Your help is greatly appreciated. Many thanks in advance! Message was edited by: francis
Super Contributor
Posts: 260

Re: Loop and validate each variables

Posted in reply to deleted_user
Hi Francis.
This is not so horrible in SAS. What you have to do with SAS is something like this :
ODS HTML FILE="c:\temp\any null.htm" ;
PROC PRINT DATA = yourDataSet (WHERE = (NMISS(OF var1-var500)>0)) LABEL ;
A few words to comment the solution :
1) the ODS HTML will produce an HTML file that contains the listing. I seemed to me that the HTML (without any limitation of page width) will be the best to read a 500-variable-wide table
2) the NMISS statistical function returns the number of missing values in a set of numeric variables
3) in the NMISS function, you can specify a list of variables. There are several ways to do that :
- NMISS(var1, var2, var3) if you feel patient enough to type all the 500 variables names
- NMISS(OF _NUMERIC_) for all numeric variables in your dataset
- NMISS(OF var3-var10) for the whole "family" of variables with names such as var3, var4, var5, ..., var9, var10. Does not work if any member of the family is missing (in my example, if there is no var7 variable, it will not execute)
- NMISS(OF varSmiley Happy for all variables having their names beginning with "VAR"
- NMISS(OF var40--x) for all variables physically stored between var40 on the left and x on the right, var40 and x being included in the selection
- NMISS(OF var40-NUMERIC-x) for a subset of the above selection, restricted to numeric variables only.

I hope you will have a working solution on time. Good luck and welcome to SAS !
Ask a Question
Discussion stats
  • 1 reply
  • 2 in conversation