pinggu2688 发表于 2011-7-8 05:37 
如果用proc sql;
create table dataset2 as
select distinct a as b
from dataset1;
quit;
这样的变量b是按照b的大小顺序排列的,而不是按照原来a的顺序排列的,请问如何可以使b的排列顺序不变?
谢谢
I believe you cannot do it with distinct, but you may bypass it as in the example below,
data t1;
do i=1 to 20;
a=ceil(ranuni(127)*5);
output;
end;
keep a;
run;
proc print;run;
proc sql;
create table t2 as
select a as b, min(N) as ord
from (
select a , monotonic() as N
from t1
)
group by 1
order by 2
;
quit;
proc print;run;