楼主: 小鳄鱼a
3933 11

求助如何按条件统计缺省值 [推广有奖]

11
huangpengfei 发表于 2014-9-1 22:12:04
data a1;
        set a;
        if dcost=. and lag(dcost) ne . then y=1;
                else y+1;
        if dcost ne . then y=.;
run;

proc sort data=a1;
        by stkcd dadtunit  descending y ;
run;

data a2;
        set a1;
        by stkcd dadtunit descending y;
        retain c;
        if first.dadtunit and first.y then c=y;
        if y=. then c=.;
        drop y;
run;

试试看有没有问题?
另,你的数据能不恩能不能不要论坛币啊?
已有 1 人评分论坛币 热心指数 收起 理由
小鳄鱼a + 5 + 1 精彩帖子

总评分: 论坛币 + 5  热心指数 + 1   查看全部评分

12
小鳄鱼a 发表于 2014-9-2 08:55:09
huangpengfei 发表于 2014-9-1 22:12
data a1;
        set a;
        if dcost=. and lag(dcost) ne . then y=1;
谢谢,已经解决了

您需要登录后才可以回帖 登录 | 我要注册

本版微信群
加好友,备注cda
拉您进交流群
GMT+8, 2025-12-31 05:42