BookmarkSubscribeRSS Feed
Miracle
Barite | Level 11

Dear SAS users,

 

Can I please ask how to output all the id's with missing values for a variable at all visits if my data is a long data with visit-specific rows by id?

 

Thank you in advance.

2 REPLIES 2
Jagadishkatam
Amethyst | Level 16

Could you please provide sample data and expected output so as to get better responses.

 

As per your question, you can try to use the below code if it helps.

 

data want;
set have;
if missing(variable) then output;
run;
Thanks,
Jag
novinosrin
Tourmaline | Level 20

Hello @Miracle   I believe this is likely what you are after

 

/*Creating your sample data*/
data have;
do id=1 to 5;
 do visit=1 to int(ranuni(0)*10);
  var=ifn(mod(id,2)=0,.,ranuni(5));
  output;
 end;
end;
run;
/*Solution*/
proc sql;
create table want as
select *
from have
group by id
having n(id)=nmiss(var)
order by id,visit;
quit;

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

How to connect to databases in SAS Viya

Need to connect to databases in SAS Viya? SAS’ David Ghan shows you two methods – via SAS/ACCESS LIBNAME and SAS Data Connector SASLIBS – in this video.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 2 replies
  • 933 views
  • 0 likes
  • 3 in conversation