全部版块 我的主页
论坛 计量经济学与统计论坛 五区 计量经济学与统计软件 Stata专版
2679 3
2024-05-23
我想把数据从宽数据转为长数据,用reshape语句一直报错是为什么?求各位大佬帮助
variable id does not uniquely identify the observations
    Your data are currently wide. You are performing a reshape long. You
    specified i(i) and j(year). In the current wide form, variable i should
    uniquely identify the observations. Remember this picture:

         long                                wide
        +---------------+                   +------------------+
        | i   j   a   b |                   | i   a1 a2  b1 b2 |
        |---------------| <--- reshape ---> |------------------|
        | 1   1   1   2 |                   | 1   1   3   2  4 |
        | 1   2   3   4 |                   | 2   5   7   6  8 |
        | 2   1   5   6 |                   +------------------+
        | 2   2   7   8 |
        +---------------+
    Type reshape error for a list of the problem observations.

我的reshape语句报错(上)

key variables do not uniquely identify the observations
我的gather同样会有报错(上)
i        a1        a2        a3
1        58.3        60.51        62.19
2        45.5        46.57        47.06
3        38.9        39.61        39.72


这是我的数据格式(上)
二维码

扫码加我 拉你入群

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

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

全部回复
2024-5-23 15:57:16
第一行说了  id不是唯一的
你给出的数据格式是没问题的  但是你实际数据是有问题的
二维码

扫码加我 拉你入群

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

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

2024-5-26 11:41:39
你可以尝试一下:
duplicates drop id,force
reshape long 变量,i()j()
二维码

扫码加我 拉你入群

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

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

2024-6-30 10:38:29
应该是id有重复值
二维码

扫码加我 拉你入群

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

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

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

说点什么

分享

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