全部版块 我的主页
论坛 计量经济学与统计论坛 五区 计量经济学与统计软件 Stata专版
4720 10
2012-11-04
悬赏 500 个论坛币 已解决
问一个panel data的数据处理问题, 数据要求连续至少10年。

在我的数据中,比方说有这样两家公司

公司A,是这样子的11.1.1111111111.1.1(有连续的十个1).
公司B,是这样子的1..111111111111.1(有连续的十二个1)

通过命令处理以后,我想得到,公司A: 1111111111(有连续的十个1);公司B:111111111111(有连续的十二个1)。我想一家一家公司的试试AR 回归不想中间有任何断点。

用下面的命令不行啊
xtpattern, gen(pat)
tab pat
gen p10=strpos(pat, "1111111111")
tab p10
drop if p10==0

最佳答案

大白菜2012 查看完整内容

You may within Stata . copy http://fmwww.bc.edu/ec-p/baum/xtpattern2.ado . and you must also . ssc install spell If you don't have this installed. Then it will do this job, as xtpattern2, gen(p2) con(consec) where the 'con' argument will be a (new) integer variable containing the greatest number of consecutive observations, including any missing from all panels. see th ...
二维码

扫码加我 拉你入群

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

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

全部回复
2012-11-4 21:50:52
econfj 发表于 2012-11-6 01:15
大白菜兄,我还是不明白怎么解决这个问题,还望指教,谢谢:)
You may within Stata

. copy http://fmwww.bc.edu/ec-p/baum/xtpattern2.ado .

and you must also

. ssc install spell

If you don't have this installed. Then it will do this job, as

xtpattern2, gen(p2) con(consec)

where the 'con' argument will be a (new) integer variable containing the greatest number of consecutive observations, including any missing from all panels.




see this,

http://www.stata.com/statalist/archive/2002-08/msg00196.html
二维码

扫码加我 拉你入群

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

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

2012-11-4 23:53:09
webuse nlswork,clear

xtpattern, gen(pat)
tab pat

gen mark=strmatch(pat,"1111111111.*") | strmatch(pat,"*.1111111111.*") | strmatch(pat,"*.1111111111")


tab mark

l pat mark if mark==1
二维码

扫码加我 拉你入群

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

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

2012-11-5 00:30:55
大白菜2012 发表于 2012-11-4 23:53
webuse nlswork,clear

xtpattern, gen(pat)
谢谢大白菜,

不过您的回答,跟我原来的程序是一个意思,但是,我要只是中间十个1其他的全部删除
xtpattern, gen(pat)
tab pat
gen p10=strpos(pat, "1111111111")
tab p10
drop if p10==0
二维码

扫码加我 拉你入群

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

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

2012-11-5 00:43:17
econfj 发表于 2012-11-5 00:30
谢谢大白菜,

不过您的回答,跟我原来的程序是一个意思,但是,我要只是中间十个1其他的全部删除
是一样的么????
一样么?
么?

. webuse nlswork,clear
(National Longitudinal Survey.  Young Women 14-26 years of age in 1968)

.
. xtpattern, gen(pat)

.
.
. gen mark=strmatch(pat,"1111111111.*") | strmatch(pat,"*.1111111111.*") | strmatch(pat,"*.1111111111")

.
. gen p10=strpos(pat, "1111111111")

.
. tab1 mark p10

-> tabulation of mark  

       mark |      Freq.     Percent        Cum.
------------+-----------------------------------
          0 |     27,088       94.93       94.93
          1 |      1,446        5.07      100.00
------------+-----------------------------------
      Total |     28,534      100.00

-> tabulation of p10  

        p10 |      Freq.     Percent        Cum.
------------+-----------------------------------
          0 |     22,360       78.36       78.36
          1 |      2,313        8.11       86.47
          2 |        605        2.12       88.59
          3 |      1,065        3.73       92.32
          4 |        772        2.71       95.03
          5 |        586        2.05       97.08
          6 |        833        2.92      100.00
------------+-----------------------------------
      Total |     28,534      100.00



your code just considers the substrings starting from "1111111111", which also include others such as "1111111111111".

But mine does answer your Q: 任何位置上连续的十个1,去除11个1或者12个1.。。
二维码

扫码加我 拉你入群

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

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

2012-11-5 08:57:03
试下这个可不可以。
xtpattern, gen(pat)
keep if pat == "1111111111"
二维码

扫码加我 拉你入群

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

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

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

说点什么

分享

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