全部版块 我的主页
论坛 数据科学与人工智能 数据分析与数据科学 SAS专版
1588 4
2014-11-12
idAstart yearend yeartran date

1

1

1990

1995

1994

1

1

1990

1995

1995

1

0

1994

1

0

1997

1

0

2002

1

0

1998

1

0

1989

1

1

1996

2001

1996

1

1

1996

2001

1999



这是data的一部分,要在每个id内找出当A=0的tran date有没有在每一个A=1的start year和end year之间。
所以我们从这个例子可以得到
firm idAceo start yearceo end yeartran date

1

1

1990

1995

1994

1

1

1990

1995

1995

1

0

1994

1

0

1997

1

0

1998

1

0

       1996       2001

1996

1

0

       1996       2001

1999

因为1989不在(1990-1995)之间也不在(1996-2001),2002不在(1990-1995)之间也不在(1996-2001)。

我以为可以create A=0和每个A=1的pair,但是这样其他变数不知道怎么办。

有请各位大神帮帮忙,拜托,感谢。





二维码

扫码加我 拉你入群

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

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

全部回复
2014-11-13 00:27:28
复制代码
二维码

扫码加我 拉你入群

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

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

2014-11-17 22:40:46
如果start year和end year中间无断档,可以使用,否则不可以使用

data test;
        input id        A        startyear        endyear        trandate @@ ;
        datalines;
1 1 1990 1995 1994
1 1 1990 1995 1995
1 0 . . 1994
1 0 . . 1997
1 0 . . 2002
1 0 . . 1998
1 0 . . 1989
1 1 1996 2001 1996
1 1 1996 2001 1999
;
run;

proc sort data=test ;
        by id descending a startyear ;
run;

data want;
        set test;
        by id descending a startyear ;
        retain sy1 ey1;
        if first.a then sy1=lag(startyear);
        if endyear>lag(endyear) then ey1=endyear;
        if trandate>=sy1 and trandate=<ey1;
        drop sy1 ey1;
run;
二维码

扫码加我 拉你入群

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

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

2015-5-15 16:24:12
huangpengfei 发表于 2014-11-17 22:40
如果start year和end year中间无断档,可以使用,否则不可以使用

data test;
感謝!
二维码

扫码加我 拉你入群

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

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

2015-5-15 16:24:49
mingfeng07 发表于 2014-11-13 00:27
謝謝!
二维码

扫码加我 拉你入群

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

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

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

说点什么

分享

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