Thank you for your reply. I try to use the find to position different AVALC based on the rule, but looks like not a good idea proc sort data=have out=ahve_1_4 (keep=usubjid ADY AVALC ); by usubjid ; run; data have_2_4; set have_1_4; if AVALC= "Y" then do;AVALC_1 ="Y";seq=0;end; if AVALC= "N" then do;AVALC_1 ="N";seq=1;end; if AVALC= "N" and ADY = . then do;AVALC_1 ="M";seq=2;end; run; proc sort ; by usubjid ; run; data have_3_4;; set have_2_4; by USUBJID ; retain p .; if first.usubjid then p=1; else p+1; run; proc transpose data=have_3_4 out=have_5; by usubjid; var AVALC_1 ; run; data have_6; set have_5; /*length col $800.;*/ col=catx(",",col1, col2,col3, col4, col5,col6 ,col7, col8, col9, col10,col11,col12,col13,col14); /*if col NOT in (&rvar) then delete;*/ keep usubjid col; run; data have_7; set have_6; p1 = findc(col,',','i',find(col,'Y,M','i')); p2 = findc(col,',','i',find(col,',M','i')); p3 = findc(col,',','i',find(col,',N','i')); p4 = findc(col,',','i',find(col,'M,M','i')); p5 = findc(col,',','i',find(col,'N,Y','i')); p6 = findc(col,',','i',find(col,',Y','i')); p7 = length(col) - length(scan(col, -1, 'N') ); run;
... View more