data have;
infile cards missover;
input obs name $;
cards;
1 5
2 7
3 haha
4 0
5
6 6
7 4
8 3
9 haha
;
proc transpose data=have out=have_tr;
var name;
id obs;
run;
data want(keep=obs name);
set have_tr;
array d(*)_1-_9;
do i=1 to dim(d);
if d(i)="haha" then do;
if i ne 1 then do;
obs=i-1;
name=d(i-1);
output;
end;
obs=i;
name=d(i);
output;
if i ne dim(d) then do;
obs=i+1;
name=d(i+1);
output;
end;
end;
end;
run;
最后的名为want的数据集便是所需要的



雷达卡
京公网安备 11010802022788号







