全部版块 我的主页
论坛 计量经济学与统计论坛 五区 计量经济学与统计软件 Stata专版
14502 15
2015-04-12
悬赏 200 个论坛币 已解决
RT,我的数据是07-13年的非平衡面板。
想把那些没有三年连续观测值的公司删除掉。
例如某公司只有07,08或者只有07,10,11年的数据,就把这个公司剔除掉,具体操作应该如何实现?
假设我的panelvar是company,timevar是year……
多谢啦~!

最佳答案

hplcdadong 查看完整内容

Real data may be very complex. The following is a fake example and the solution of my best guess of what you want . clear input company year x 1 2007 78 1 2008 89 1 2010 142 1 2011 211 2 2007 88 2 2008 451 2 2009 156 2 2011 254 2 2012 122 3 2010 111 3 2011 58 3 2012 54 3 2013 325 4 2007 99 4 2008 109 end tsset company year ssc install tsspell, replace //onetime instal ...
二维码

扫码加我 拉你入群

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

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

全部回复
2015-4-12 22:37:53
Real data may be very complex. The following is a fake example and the solution of my best guess of what you want .

clear
input company year x
1 2007 78
1 2008 89
1 2010 142
1 2011 211
2 2007 88
2 2008 451
2 2009 156
2 2011 254
2 2012 122
3 2010 111
3 2011 58
3 2012 54
3 2013 325
4 2007 99
4 2008 109
end

tsset company year

ssc install tsspell, replace    //onetime install the user-written command tsspell
tsspell, f(L.year == .)
by company: egen maxrun = max(_seq)
keep if maxrun>=3         //my best guess of what you want
二维码

扫码加我 拉你入群

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

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

2015-4-12 23:23:11
复制代码
留下来的就是有三年连续观测值的公司
二维码

扫码加我 拉你入群

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

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

2015-4-13 10:22:59
西北426 发表于 2015-4-12 23:23
留下来的就是有三年连续观测值的公司
code不合适哦。

三楼还是蛮不错的。

二维码

扫码加我 拉你入群

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

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

2015-4-13 10:30:15
西北426 发表于 2015-4-12 23:23
留下来的就是有三年连续观测值的公司
请问x和y代表啥?……
二维码

扫码加我 拉你入群

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

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

2015-4-13 12:15:49
SpencerMeng 发表于 2015-4-13 10:22
code不合适哦。

三楼还是蛮不错的。
嘿嘿,晓得,我自然是在抛砖引玉了,哈哈
二维码

扫码加我 拉你入群

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

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

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

说点什么

分享

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