全部版块 我的主页
论坛 计量经济学与统计论坛 五区 计量经济学与统计软件 Stata专版
1023 4
2022-03-08
patentid        variable        value
2951        专利分类号1        B21D
2951        专利分类号2        C21D

上面变量如何变成
patentid        专利分类号1        专利分类号1
  2951              B21D                  C21D

二维码

扫码加我 拉你入群

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

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

全部回复
2022-3-8 19:20:54
Andrew Musau 建议:
复制代码
二维码

扫码加我 拉你入群

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

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

2022-3-8 20:34:11
黃河泉 发表于 2022-3-8 19:20
Andrew Musau 建议:
你好,黄老师!
我是这样做的:
gen ipc =substr( variable ,-1,1)
destring  ipc , replace force   
drop variable
reshape wide value,i( patentid )j( ipc )
但是结果还是出错,如下图
values of variable ipc not unique within patentid
    Your data are currently long. You are performing a reshape wide. You specified i(patentid)
    and j(ipc). There are observations within i(patentid) with the same value of j(ipc). In the
    long data, variables i() and j() together must uniquely identify the observations.

         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 variables.
二维码

扫码加我 拉你入群

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

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

2022-3-8 20:36:30
黃河泉 发表于 2022-3-8 19:20
Andrew Musau 建议:
stata提示我的意思是:变量ipc的值在patentid内不唯一,也就是同一个patentid对应有相同的ipc数值,但是我查了下都是不相同的啊?
二维码

扫码加我 拉你入群

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

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

2022-3-9 07:54:01
henanlixiaokai1 发表于 2022-3-8 20:36
stata提示我的意思是:变量ipc的值在patentid内不唯一,也就是同一个patentid对应有相同的ipc数值,但是我 ...
无从评论!
二维码

扫码加我 拉你入群

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

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

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

说点什么

分享

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