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
SAS Super FREQ
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
SAS Super FREQ
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.

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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.

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