i have a data like this
| VisitDate | PatientID | IncidentID | Specimenr source | testtype | result | Treatment_Date1 | Treatment1 |
| 7/6/2017 | 272358 | 2773233 | p | 1 | 0 | 7/6/2017 | Ceftriaxone 250 mg IM |
| 7/6/2017 | 272358 | 2773233 | u | 2 | 1 | 7/6/2017 | Ceftriaxone 250 mg IM |
| 7/17/2017 | 272358 | 2773233 | ur | 1 | 0 | 7/6/2017 | Ceftriaxone 250 mg IM |
| 7/17/2017 | 272358 | 2773233 | e | 1 | 0 | 7/6/2017 | Ceftriaxone 250 mg IM |
| 7/17/2017 | 259981 | 2783394 | ur | 2 | 1 | ######## | Ceftriaxone 250 mg IM |
| 7/17/2017 | 259981 | 2783394 | p | 1 | 1 | ######## | Ceftriaxone 250 mg IM |
| 7/17/2017 | 259981 | 2783394 | r | 2 | 1 | ######## | Ceftriaxone 250 mg IM |
| 7/17/2017 | 259981 | 2783394 | v | 1 | 0 | ######## | Ceftriaxone 250 mg IM |
and i want it to be like this
| CollDate | PatientID | IncidentID | Specimenr source1 | Specimenr source2 | Specimenr source3 | Specimenr source4 | testtype1 | testtype2 | testtype3 | testtype4 | result1 | result2 | result3 | result4 | Treatment_Date1 | Treatment1 |
| 7/6/2017 | 272358 | 2773233 | p | u | ur | e | 1 | 2 | 1 | 1 | 0 | 1 | 0 | 0 | 7/6/2017 | Ceftriaxone 250 mg IM in a single dose AND same day treatment with Azithromycin 1g orally in a single dose (Gonorrhea) |
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;
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
Still thinking about your presentation idea? The submission deadline has been extended to Friday, Nov. 14, at 11:59 p.m. ET.
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.
Ready to level-up your skills? Choose your own adventure.