Good evening!
I am looking to merge by ID, but I do not want to sum each occurrence. Instead-- no matter how many "1's" are present I only want to indicate it once. I'm finding it difficult to explain so hopefully the below example is helpful.
Have:
ID | Visit ID | Fibro | DPN | Seiz | RLS | OD | OPABUSE | Chonic | MHD |
5 | 15651 | 0 | 0 | 1 | 0 | 0 | 1 | 1 | 0 |
5 | 15670 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 1 |
5 | 16082 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 1 |
5 | 17082 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 1 |
5 | 18069 | 0 | 0 | 0 | 0 | 0 | 1 | 1 | 1 |
5 | 18071 | 0 | 0 | 0 | 0 | 0 | 1 | 1 | 1 |
5 | 19025 | 1 | 0 | 0 | 0 | 0 | 0 | 1 | 1 |
5 | 19126 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 1 |
Want:
ID | Visit ID | Fibro | DPN | Seiz | RLS | OD | OPABUSE | Chronic | MHD |
5 | 1 | 0 | 1 | 0 | 0 | 1 | 1 | 1 |
As always, I'm extremely grateful to the community!!
Thanks!
Your question doesn't match the subject line. You do not appear to be doing any merging.
If your variables are coded 0 and 1 then you appear to want the max value.
proc summary nway data=have ;
class id;
var Fibro DPN Seiz RLS OD OPABUSE Chonic MHD ;
output out=want max= ;
run;
Your question doesn't match the subject line. You do not appear to be doing any merging.
If your variables are coded 0 and 1 then you appear to want the max value.
proc summary nway data=have ;
class id;
var Fibro DPN Seiz RLS OD OPABUSE Chonic MHD ;
output out=want max= ;
run;
Thank you for your quick reply!
Yup, I definitely was thinking through this all wrong.
I actually have many more variables in my actual data set. Is there an easy way to use the code provided and keep all the other variables?
proc means data=have noprint nway;
class id;
output out=want(drop=_type_ _freq_) max=;
run;
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!
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.