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

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:

IDVisit IDFibro DPNSeizRLSODOPABUSEChonic MHD
51565100100110
51567000000011
51608200000011
51708200000011
51806900000111
51807100000111
51902510000011
51912600000011

 

Want:

IDVisit IDFibro DPNSeizRLSODOPABUSEChronic MHD
5 10100111

 

As always, I'm extremely grateful to the community!!

 

Thanks!

1 ACCEPTED SOLUTION

Accepted Solutions
Tom
Super User Tom
Super User

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;

 

View solution in original post

4 REPLIES 4
Tom
Super User Tom
Super User

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;

 

ssulli11
Calcite | Level 5

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?

Tom
Super User Tom
Super User
Keep which version of the other variables?
learsaas
Quartz | Level 8
proc means data=have noprint nway;
	class id;
	output out=want(drop=_type_ _freq_) max=;
run;

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 4 replies
  • 938 views
  • 0 likes
  • 3 in conversation