Like @Kurt_Bremser suggested: Transform your data to a long structure which is much easier to work with.
data have;
infile datalines dlm= '*' truncover;
label
ID = "Participant ID"
AVSLST = "All Visits Completed"
PPCENSVSx = "Censored Visits (have)"
PPCENSVS = "Censored Visits (want)"
;
length AVSLST PPCENSVSx PPCENSVS $30.;
input ID :$6. AVSLST $ PPCENSVSx $ PPCENSVS $;
datalines;
1 * 01, 02, 03, 04, 05, 06, 07, 08 * 06, 12, 10 * 06, 10, 12
2 * 01, 02, 03, 04, 05, 06, 07 * 04, 05, 06, 07, 04, 02 * 02, 04, 05, 06, 07
3 * 01, 02, 03, 05, 06, 07, 08 * 07, 08, 03, 07, 04 * 03, 04, 07, 08
4
5 *01
6 * *01
;
run;
data long;
set have;
length visit_no 8 visit_completed_flg visit_censored_flg 3;
length _vno $5 _visits $200;
_visits=catx(',',AVSLST,PPCENSVSx);
do i=1 to countc(_visits,',')+1;
_vno=scan(_visits,i);
visit_no=input(_vno,best32.);
visit_completed_flg = (findw(AVSLST,strip(_vno))>0);
visit_censored_flg = (findw(PPCENSVSx,strip(_vno))>0);
output;
end;
keep id visit_:;
run;
proc sort data=long out=want nodupkey;
by id visit_no;
run;
... View more