turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

Find a Community

- Home
- /
- SAS Programming
- /
- SAS Procedures
- /
- Loop and validate each variables

Topic Options

- RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page

- Mark as New
- Bookmark
- Subscribe
- RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

07-09-2008 12:07 PM

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

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

- Mark as New
- Bookmark
- Subscribe
- RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to deleted_user

07-10-2008 09:09 AM

Hi Francis.

This is not so horrible in SAS. What you have to do with SAS is something like this :

[pre]

ODS HTML FILE="c:\temp\any null.htm" ;

PROC PRINT DATA = yourDataSet (WHERE = (NMISS(OF var1-var500)>0)) LABEL ;

RUN ;

ODS HTML CLOSE ;

[/pre]

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 var 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 !

Olivier

This is not so horrible in SAS. What you have to do with SAS is something like this :

[pre]

ODS HTML FILE="c:\temp\any null.htm" ;

PROC PRINT DATA = yourDataSet (WHERE = (NMISS(OF var1-var500)>0)) LABEL ;

RUN ;

ODS HTML CLOSE ;

[/pre]

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 var 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 !

Olivier