data have;
informat id best4. var1text date9. var2 $1. var1dummy best1. datetext date9.;
input ID var1text VAR2 VAR1dummy datetext;
format var1text datetext date9.;
datalines;
1 . X 0 30Apr2015
1 9May2015 . 1 31May2015
1 . . 0 30Jun2015
2 . X 0 30Apr2015
2 . . 0 31May2015
2 28Jun2015 . 1 30Jun2015
3 3Apr2015 . 1 30Apr2015
3 . . 0 31May2015
3 . X 0 30Jun2015
;
run;
data want;
do until(last.id);
set have;
by id;
if not missing(var1text) then x=var1text;
if not missing(VAR2) then y=datetext;
end;
dif=abs(x-y);
keep id dif;
run;
... View more