楼主: liuliuqiu
982 3

[问答] SAS求教 [推广有奖]

  • 6关注
  • 2粉丝

已卖:35份资源

副教授

64%

还不是VIP/贵宾

-

威望
0
论坛币
2239 个
通用积分
8.1161
学术水平
3 点
热心指数
5 点
信用等级
5 点
经验
14393 点
帖子
429
精华
0
在线时间
1129 小时
注册时间
2009-3-24
最后登录
2025-12-11

楼主
liuliuqiu 发表于 2016-4-18 09:58:03 |AI写论文

+2 论坛币
k人 参与回答

经管之家送您一份

应届毕业生专属福利!

求职就业群
赵安豆老师微信:zhaoandou666

经管之家联合CDA

送您一个全额奖学金名额~ !

感谢您参与论坛问题回答

经管之家送您两个论坛币!

+2 论坛币
求教:   id   year
   1    2001
   1    2002
   1    2004
   1    2005
   2    2002
   2    2003
   2    2004
   3    ...
以上数据有Id 和时间两个变量,其中每个个体中,时间可能是连续的,也可能是间断的,最后结果想得到时间间断的数据。
请教如何求得?
非常感谢!

二维码

扫码加我 拉你入群

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

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

关键词:year 非常感谢 ear 如何

沙发
liuliuqiu 发表于 2016-4-18 10:51:09
麻烦各位帮忙看看

藤椅
guanglei 发表于 2016-4-18 19:00:15
你这个问题似乎跟这个是反着的

https://bbs.pinggu.org/thread-4566414-1-1.html

我用那个的数据,下面的代码看能行不?

data want(keep=id);
        set text1;
        by id;
        retain lyear;
        if first.id then do;
                lyear = year;count = 1;end;
                else do;
                        if year = lyear + 1 then do; lyear = year;count+1;end;
        end ;
        if last.id and count<3 then output;
run;
已有 1 人评分学术水平 热心指数 信用等级 收起 理由
liuliuqiu + 5 + 5 + 5 热心帮助其他会员

总评分: 学术水平 + 5  热心指数 + 5  信用等级 + 5   查看全部评分

板凳
67890 发表于 2016-4-19 09:11:17
Ran on SAS 9.4 64bit base on Win10.

data orginal;
        input id year;
        cards;
   1    2001
   1    2002
   1    2004
   1    2005
   2    2002
   2    2003
   2    2004
   ;
   run;

   proc sort data=orginal out=temp01; by id year;run;
   data temp02;
           set temp01;
        lagyear=lag(year);
        by id;
        if first.id then lagyear=.;
        year_dif = year - lagyear;
        run;
        data want(drop=year_dif);
        set temp02;
        if year_dif gt 1;
        run;

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

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