Hi Kurt
I tried your code. However I end up with duplicate values of MODULE e.g. VS,VS,LB. I would only need the non-duplicate values e.g. VS,LB.
I've supplied some datalines here to investigate:
data have; INFILE DATALINES DLM="," missover; input USUBJID :$20. VISIT :$20. DATE :$20. MODULE :$20.; datalines; 101,SCREENING,2000-01-02,EG1 101,SCREENING,2000-01-02 101,UNSCHEDULED,2000-01-02,VS 101,UNSCHEDULED,2000-01-02,VS 101,UNSCHEDULED,2000-01-02,LB 101,UNSCHEDULED,2000-01-04,EG 102,SCREENING,2000-01-05 102,VISIT 1,2000-01-06 102,UNSCHEDULED,2000-01-06,VS 102,UNSCHEDULED,2000-01-07,LB 103,VISIT 1,2000-10-06,VS 103,VISIT 1,2000-10-06,VS ;
proc sort data=have; by usubjid visit date; run;
data want; set have (rename=(module=_module)); by usubjid visit date; length module $10; * set as needed for maximum number of modules; retain module; if first.date then module = ""; if findw(module,_module,",") = 0 then module = catx(",",module,_module); if last.date; drop _module; run;
... View more