BookmarkSubscribeRSS Feed
deleted_user
Not applicable
Hi All,

I have a dataset with approx 40 variables which are integer as well as string datatypes. I would like to find out number of missing values and number of non missing values for each variable and output them to a output dataset.

Rather than hardcoding the variable names in proc sql i would like to automate them.

Thanks & Regards
Samuel
4 REPLIES 4
sbb
Lapis Lazuli | Level 10 sbb
Lapis Lazuli | Level 10
test reply - ignore.
sbb
Lapis Lazuli | Level 10 sbb
Lapis Lazuli | Level 10
[Sorry - SAS website server hangs with a more detailed post]

With PROC SQL (similar to other SAS dataset option/parameter specifications), explore using the (KEEP=_NUMERIC_) parameter to select all SAS variables of a particular type.

Scott Barry
SBBWorks, Inc.
sbb
Lapis Lazuli | Level 10 sbb
Lapis Lazuli | Level 10
[So I am breaking it up into two parts]

The SAS support website http://support.sas.com/ has SAS product documentation and supplemental technical papers - the site's SEARCH facility can be used or consider the Google advanced search argument below which yields matching search results on the site using your topic (note that the site parameter must be in lowercase characters or it is ignored by Google):

proc sql data set options site:sas.com

Scott Barry
SBBWorks, Inc.
Patrick
Opal | Level 21
Hi Samuel
That should do the job.
HTH
Patrick



data have;
infile datalines truncover;
input var1 $1-2 var2 3-4 ;
datalines;
a 1
2


e 4
;
proc sql noprint;
select 'sum(missing('||name||')) as '||name into :SelList2 separated by ', '
from dictionary.columns
where libname='WORK' and memname='HAVE';

create table want as
select &SelList2
from have;
quit;

title 'N Missings per Variable';
proc print data =want noobs;
run;

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

Register Now

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 4 replies
  • 1290 views
  • 0 likes
  • 3 in conversation