data aaa1;
set aaa;
if visit=6 then treat1=substr(treat, 1,1);
else if visit>6 then treat1=substr(treat, 2,1);
run;
proc sort; by id treat1;run;
data baseline(drop=visit);
set aaa(rename=(x=x0));
if visit=2 then do; treat1=substr(treat, 1,1); output; end;
else if visit=6 then do; treat1=substr(treat, 2,1); output; end;
run;
proc sort; by id treat1;run;
data aaa2(rename=(x=x1)); ;
merge aaa1(in=a) baseline(in=b);
by id treat1;
if a and b;
run;
proc sort data=aaa2 out=aaa3(drop= visit);
by id visit;
run;
|