全部版块 我的主页
论坛 计量经济学与统计论坛 五区 计量经济学与统计软件 Stata专版
22275 18
2015-02-14
请看以下数据
code   listyr1  listyr2 ....    listyr_n
1         1990  1991  ....     2013
2         1991  1992  ....     2014
3         1995  1996  ....     2018
4         1998  1999  ....     2021


如何转换成如下的目标数据:
code   year
1         1990  
1         1991  
1         1992  
1         1993

省略
1          2013
2         1991
2         1992  
2         1993  
2         1994

省略
2          2014


我使用reshape long listyr, i(code) j(year)结果显示variable id does not uniquely identify the observations
    Your data are currently wide.  You are performing a reshape long.  You specified i(code) and
    j(year).  In the current wide form, variable code should uniquely identify the observations.
    Remember this picture.
到底怎么用才可以呢(注:code有2046个)


二维码

扫码加我 拉你入群

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

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

全部回复
2015-2-14 17:19:14
这得学习一下
二维码

扫码加我 拉你入群

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

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

2015-2-14 17:31:31
你不写出你当时的命令
其他人怎么帮你是哪里的错误
二维码

扫码加我 拉你入群

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

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

2015-2-14 18:28:47
蓝色 发表于 2015-2-14 17:31
你不写出你当时的命令
其他人怎么帮你是哪里的错误
已将命令补上
reshape long listyr, i(code) j(year),敬请诊断,谢谢!
二维码

扫码加我 拉你入群

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

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

2015-2-14 19:17:36
命令没有问题
是你数据的问题
clear
input ///
code   listyr1  listyr2
1         1990  1991  
2         1991  1992  
3         1995  1996  
4         1998  1999  
end

reshape long listyr,i(code) j(year)
list




结果
. clear

. input ///
> code   listyr1  listyr2

          code    listyr1    listyr2
  1. 1         1990  1991  
  2. 2         1991  1992  
  3. 3         1995  1996  
  4. 4         1998  1999  
  5. end

.
. reshape long listyr,i(code) j(year)
(note: j = 1 2)

Data                               wide   ->   long
-----------------------------------------------------------------------------
Number of obs.                        4   ->       8
Number of variables                   3   ->       3
j variable (2 values)                     ->   year
xij variables:
                        listyr1 listyr2   ->   listyr
-----------------------------------------------------------------------------


. list

     +----------------------+
     | code   year   listyr |
     |----------------------|
  1. |    1      1     1990 |
  2. |    1      2     1991 |
  3. |    2      1     1991 |
  4. |    2      2     1992 |
  5. |    3      1     1995 |
     |----------------------|
  6. |    3      2     1996 |
  7. |    4      1     1998 |
  8. |    4      2     1999 |
     +----------------------+

二维码

扫码加我 拉你入群

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

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

2015-2-14 20:23:16
谢谢!我再试试吧。试过了还是不行,请问数据的问题怎么查,能有什么样的问题呢?
二维码

扫码加我 拉你入群

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

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

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

说点什么

分享

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