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;
Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.
If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website.
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.