不过上面保留的结果,都是排过序了。
用下面的程序,可以保留原始观测,这里默认保留第一个出现的观测:
data ex;
input (n1-n3)( $);
cards;
b c a
c b a
a c b
;
run;
data ex1;
set ex;
length new $50.;
call sortc(of n1-n3);
new=cats(of n1-n3);
data ex1;
merge ex1(keep=new) ex;
run;
data _null_;
if _n_=1 then do;
declare hash h();
h.definekey('new');
h.definedata('n1','n2','n3');
h.definedone();
end;
set ex1 end=last;
if h.find() then h.add();
if last then h.output(dataset:'ex2');
run;
|