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.
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;
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;
Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.
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.