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 2024

Innovate_SAS_Blue.png

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. 

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.

Get the $99 certification deal.jpg

 

 

Back in the Classroom!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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