BookmarkSubscribeRSS Feed
Dhana18
Obsidian | Level 7

i have a data like this

VisitDatePatientIDIncidentIDSpecimenr sourcetesttyperesultTreatment_Date1Treatment1
7/6/20172723582773233p107/6/2017Ceftriaxone 250 mg IM 
7/6/20172723582773233u217/6/2017Ceftriaxone 250 mg IM 
7/17/20172723582773233ur107/6/2017Ceftriaxone 250 mg IM 
7/17/20172723582773233e107/6/2017Ceftriaxone 250 mg IM 
7/17/20172599812783394ur21########Ceftriaxone 250 mg IM 
7/17/20172599812783394p11########Ceftriaxone 250 mg IM 
7/17/20172599812783394r21########Ceftriaxone 250 mg IM 
7/17/20172599812783394v10########Ceftriaxone 250 mg IM 

 

 and i want it to be like this

CollDatePatientIDIncidentIDSpecimenr source1Specimenr source2Specimenr source3Specimenr source4testtype1testtype2testtype3testtype4result1result2result3result4Treatment_Date1Treatment1
7/6/20172723582773233puure121101007/6/2017Ceftriaxone 250 mg IM in a single dose AND same day treatment with Azithromycin 1g orally in a single dose (Gonorrhea)
5 REPLIES 5
Ksharp
Super User

CODE NOT TESTED

 

proc sql;
select max(n) into :n 
from (
select count(*) as n
 from have
  group by VisitDate,	PatientID,	IncidentID
);
quit;

proc summary data=have;
by VisitDate	PatientID	IncidentID;
output out=want idgroup(out[&n] (Specimenrsource	testtype	result	Treatment_Date1	Treatment1)=);
run;
Cynthia_sas
Diamond | Level 26
Hi:
Are CollDate and VisitDate the same? I don't see CollDate in the data you posted. Also, the text you show for Treatment1 under desired results is not found in your original data that you posted.

Cynthia
Dhana18
Obsidian | Level 7
Yes, the visit date and the collect date are the same.
Cynthia_sas
Diamond | Level 26
What do the ##### mean for Treatment_Date1? And why is the value for Treatment1 different in the first table than you show in the second table?

Cynthia
andreas_lds
Jade | Level 19
@Dhana18: please post data in usable form.

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

Register Now

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

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
  • 5 replies
  • 1025 views
  • 0 likes
  • 4 in conversation