全部版块 我的主页
论坛 数据科学与人工智能 数据分析与数据科学 SAS专版
1402 3
2014-01-15
悬赏 100 个论坛币 已解决
有一个数据列A:(这个数据  行 很长,我这里是举一个简单的例子)
X
10
2
3
.
.
.
7
5
9
1
.
.
.
.
.
41
.
12
.
我要对X编号,产生一列NUM:
规则是:1.X的顺序不变,不用排列     2.数字 和 点. 单独排序,间隔后重新排序。
结果应该是这样的结构:

X     num
10   1
7     2
3     3
.      1
.     2
.     3
7    1
5    2
9    3
1    4
.      1
.      2
.      3
.      4
.      5
41    1
.       1
12    1
.       1

.       2

求大神赐教,谢谢!!!

最佳答案

wwang111 查看完整内容

data wanted; set a; if x ne . and lag(x)=. then num1=0; num1+1; if lag(x) ne . and x=. then num2=1; if x=. and lag(x)=. then num2+1; if (x ne . and lag(x)=.) or (x ne . and lag(x) ne .) then num=num1; else num=num2; keep x num; run;
二维码

扫码加我 拉你入群

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

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

全部回复
2014-1-15 13:29:12
data wanted;
set a;
if x ne . and lag(x)=. then num1=0;
num1+1;
if lag(x) ne . and x=. then num2=1;
if x=. and lag(x)=. then num2+1;
if (x ne . and lag(x)=.) or (x ne . and lag(x) ne .) then num=num1;
else num=num2;
keep x num;
run;
二维码

扫码加我 拉你入群

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

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

2014-1-15 14:07:36
wwang111 发表于 2014-1-15 14:00
data wanted;
set a;
if x ne . and lag(x)=. then num1=0;
怎么支付论坛币?
二维码

扫码加我 拉你入群

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

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

2014-1-15 14:09:12
我也不清楚,不用了啊,没事。
二维码

扫码加我 拉你入群

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

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

栏目导航
热门文章
推荐文章

说点什么

分享

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