[code:ygs62kio]data b;
set a;
by var;
retain _value;
if first.var then _value = value; *(Re-)initialize the retained value;
if nmiss(value) then value = _value; *replace only missing by the afore-record;
_value = value; *renew the value ;
drop _value;
run;[/code:ygs62kio]