Here's a (perhaps) simpler approach that doesn't require learning PROC TRANSPOSE:
data want;
set have (rename=(fev1=fev));
by mrn dos bmi;
fev2 = fev;
fev1 = lag(fev);
if last.bmi;
drop fev;
run;
It does require, however, that there are exactly two observations to be combined each time. If that's not the case, you can still use a more complex DATA step or else switch to PROC TRANSPOSE:
proc transpose data=have (rename=(fev1=fev)) prefix=fev out=want (drop=_name_);
var fev;
by mrn dos bmi;
run;
The programs are untested ... likely working as is but you may need to tweak them.
... View more