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: Call for Content

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!

Submit your idea!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

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

View all other training opportunities.

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