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;

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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