全部版块 我的主页
论坛 数据科学与人工智能 数据分析与数据科学 SAS专版
8454 6
2013-08-13
悬赏 50 个论坛币 已解决
例如,我有如下数据集:

data aaa;
input x $ @@;
cards;
a a s s d d f f d s d a f s d a f s
;
run;

我就想把x按照:a d s f(我自己指定的顺序)排序,请问有无办法,谢谢。

我不想用衍生变量,我希望寻求直接的方法。

最佳答案

ziyenano 查看完整内容

data aaa; input x $ @@; cards; a a s s d d f f d s d a f s d a f s ; run; data tmp; input x $ @@; id=_n_; cards; a d s f ; run; proc sql; create table bbb as select t.x from aaa t inner join tmp t1 on t.x=t1.x order by t1.id; quit; 这个算不算辅助变量?
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

全部回复
2013-8-13 10:20:02
data aaa;
input x $ @@;
cards;
a a s s d d f f d s d a f s d a f s
;
run;

data tmp;
input x $ @@;
id=_n_;
cards;
a d s f
;
run;

proc sql;
create table bbb as
select t.x from
aaa t
inner join
tmp t1
on t.x=t1.x
order by t1.id;
quit;

这个算不算辅助变量?

二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

2013-8-13 10:32:26
you can define a auxiliary variable as below and sort by that auxiliary variable.

proc format ;
value $myorder
a=1
d=2
s=3
f=4
;
run;

data aaa;
input x $ @@;
xorder=put(x, $myorder.);
cards;
a a s s d d f f d s d a f s d a f s
;
run;

proc sort data=aaa; by xorder; run;

proc print;run;
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

2013-8-13 10:52:47
bobguy 发表于 2013-8-13 10:32
you can define a auxiliary variable as below and sort by that auxiliary variable.

proc format ;
Yes. Auxiliary variable must be the effectively way to deal with the problem. But I only wonder if here exist another directly way, such a proc stop, a option in proc sort, to solve this problem.
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

2013-8-13 12:46:23
复制代码
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

2016-1-6 16:07:59
{:3_42:}
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

点击查看更多内容…
相关推荐
栏目导航
热门文章
推荐文章

说点什么

分享

扫码加好友,拉您进群
各岗位、行业、专业交流群