黃河泉 发表于 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.