楼主: econfj
4797 10

[数据管理求助] 问一个panel data的数据处理问题 [推广有奖]

  • 1关注
  • 3粉丝

已卖:2份资源

教授

19%

还不是VIP/贵宾

-

威望
0
论坛币
32534 个
通用积分
28.9504
学术水平
1 点
热心指数
5 点
信用等级
2 点
经验
1020 点
帖子
456
精华
0
在线时间
1621 小时
注册时间
2010-4-2
最后登录
2022-7-14

楼主
econfj 发表于 2012-11-4 21:50:51 |AI写论文
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 ...
关键词:panel data 数据处理问题 Panel Data pane 断点 数据分析专题 数据处理 数据分析软件 数据分析报告 面板数据分析 excel数据分析 数据分析方法 项目数据分析

本帖被以下文库推荐

沙发
大白菜2012 发表于 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
已有 1 人评分经验 论坛币 学术水平 热心指数 收起 理由
crystal8832 + 10 + 10 + 1 + 1 补偿

总评分: 经验 + 10  论坛币 + 10  学术水平 + 1  热心指数 + 1   查看全部评分

元芳,侬怎么L00K?

藤椅
大白菜2012 发表于 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
已有 1 人评分经验 论坛币 学术水平 热心指数 收起 理由
crystal8832 + 10 + 10 + 1 + 1 观点有启发

总评分: 经验 + 10  论坛币 + 10  学术水平 + 1  热心指数 + 1   查看全部评分

元芳,侬怎么L00K?

板凳
econfj 发表于 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 发表于 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.。。
已有 1 人评分热心指数 收起 理由
crystal8832 + 1 鼓励积极发帖讨论

总评分: 热心指数 + 1   查看全部评分

元芳,侬怎么L00K?

地板
ywh19860616 发表于 2012-11-5 08:57:03
试下这个可不可以。
xtpattern, gen(pat)
keep if pat == "1111111111"
一份耕耘,一份收获。

7
launch878 发表于 2012-11-5 22:17:38
大白菜2012 发表于 2012-11-5 00:43
是一样的么????
一样么?
么?
学习

8
econfj 发表于 2012-11-5 22:28:07
大白菜2012 发表于 2012-11-5 00:43
是一样的么????
一样么?
么?
你的方法和我的,的确不一样,实在抱歉,我没有说明白我的意图,我重新编辑了帖子。不过你的方法,用在别的地方不错,要不你上传一个东西,设置两百币,我来买,谢谢!

9
大白菜2012 发表于 2012-11-5 22:38:38
econfj 发表于 2012-11-5 22:28
你的方法和我的,的确不一样,实在抱歉,我没有说明白我的意图,我重新编辑了帖子。不过你的方法,用在 ...
that's fine. I think you have known how to fix it.

good luck!

元芳,侬怎么L00K?

10
econfj 发表于 2012-11-6 01:15:10
大白菜2012 发表于 2012-11-5 22:38
that's fine. I think you have known how to fix it.

good luck!
大白菜兄,我还是不明白怎么解决这个问题,还望指教,谢谢:)

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

本版微信群
加好友,备注jltj
拉您入交流群
GMT+8, 2025-12-28 17:13