如何用SAS语句将数据集中相同的观测值去掉
发布网友
发布时间:2022-04-29 03:26
我来回答
共1个回答
热心网友
时间:2023-10-09 04:58
给你贴个两变量的程序吧,unique就是所有不一样的观测数据集。tmp是原始的数据集
proc sort data=work.tmp; by X1-X2;run;
data unique else;
set tmp;
by X1 X2;
if first.X1 then x1last=999;
if first.X2 then x2last=999;
if X1 ne x1last then do;
output unique;
x1last=X1;
if X2 ne x2last then x2last=X2;
end;
else do;
if X2 ne x2last then do;
output unique;
x2last=X2;
end;
else output else;
end;
retain x1last x2last;
drop x1last x2last;
run;
热心网友
时间:2023-10-09 04:58
给你贴个两变量的程序吧,unique就是所有不一样的观测数据集。tmp是原始的数据集
proc sort data=work.tmp; by X1-X2;run;
data unique else;
set tmp;
by X1 X2;
if first.X1 then x1last=999;
if first.X2 then x2last=999;
if X1 ne x1last then do;
output unique;
x1last=X1;
if X2 ne x2last then x2last=X2;
end;
else do;
if X2 ne x2last then do;
output unique;
x2last=X2;
end;
else output else;
end;
retain x1last x2last;
drop x1last x2last;
run;
热心网友
时间:2023-10-09 04:58
给你贴个两变量的程序吧,unique就是所有不一样的观测数据集。tmp是原始的数据集
proc sort data=work.tmp; by X1-X2;run;
data unique else;
set tmp;
by X1 X2;
if first.X1 then x1last=999;
if first.X2 then x2last=999;
if X1 ne x1last then do;
output unique;
x1last=X1;
if X2 ne x2last then x2last=X2;
end;
else do;
if X2 ne x2last then do;
output unique;
x2last=X2;
end;
else output else;
end;
retain x1last x2last;
drop x1last x2last;
run;