BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
lalohg
Quartz | Level 8

Hello there,

I need to get the list of id for all variables with missing entries and also the cross tabulations of non-missing entries for all variables excluding long list of variables to print (for instance dates or id)

 

for example:

 

proc freq data=x;

tables _all_/nopercent nocum; also, would like to exclud some long list variables la dates how do I exclude specific variables?

run;

 

example: the output would look like:

sex   N=

F      10

M      20

Missing 10

Id of missing

1,2,3,4,5,6,7,8,9,10

 

your help will be very much appreciated it

 

Thanks 

Lalohg

 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
SuryaKiran
Meteorite | Level 14

How do you want to include then?

 

One way is use OUTPUT in the do loop, which returns all rows and only the last. will contain the list of id's missing.

 

data want;
format id_list $50.;
do until (last.gender);
set have;
by gender;
if first.gender then count=1;
else count+1;
id_list=strip(id_list)||","||strip(put(id,3.));
output;
end;
run;
Thanks,
Suryakiran

View solution in original post

4 REPLIES 4
SuryaKiran
Meteorite | Level 14

I don't think you can get the list of missing id's in proc freq. You can try something like this:

data have;
infile datalines missover;
input id gender $;
datalines ;
1 M
2 F
3
4 M
5 
6 M
7 
8 F
;
run;
proc sort data=have;
by gender;
run;
data want(drop=id);
format id_list $50.;
do until (last.gender);
set have;
by gender;
if first.gender then count=1;
else count+1;
id_list=strip(id_list)||","||strip(put(id,3.));
end;
run;
Thanks,
Suryakiran
lalohg
Quartz | Level 8
Thanks SuryaKiran,

It worked great! but I have a data set with several variables, is there a
way to include all variables?

Thanks

Lalo
SuryaKiran
Meteorite | Level 14

How do you want to include then?

 

One way is use OUTPUT in the do loop, which returns all rows and only the last. will contain the list of id's missing.

 

data want;
format id_list $50.;
do until (last.gender);
set have;
by gender;
if first.gender then count=1;
else count+1;
id_list=strip(id_list)||","||strip(put(id,3.));
output;
end;
run;
Thanks,
Suryakiran

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!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

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
  • 748 views
  • 0 likes
  • 2 in conversation