/*空行是字符型缺失,所以你的x值要转为字符型*/
data bbb;
set aaa nobs=last;
x_new=strip(x);
if (x_new^=lag(x_new) and _n_ ^=1) then
do;
temp=x_new;
call missing(x_new);
output;
x_new=temp;
end;
output;
if _n_=last then
do;
call missing(x_new);
output;
end;
rename x_new=x;
drop temp x;
run;