本来想自己定义宏来做,我的思路是打开第二个表格,preserve,打开第一个表格 local 四个时间截点和两个id, restore, 让Rptdt2 和两个id 与生成的宏进行比对,生成x。但是写的命令失败了,请教一下大家了!
这是我写的错误代码:
use 2.dta
preserve
use 1.dta
local win1 `r(pre_min)
local win2 `(pre_max)
local win3 `(post_min)
local win4 `(post_max)
local institu InstitutionID
local idd id
restore
gen x=1 if InstitutionID== `institu' & Rptdt2> `win1' & Rptdt2< `win2' & id!=`idd'
replaca x=1 if InstitutionID== `institu' & Rptdt2> `win3' & Rptdt2< `win4' & id!=`idd'
这里是数据:
* Example generated by -dataex-. To install: ssc install dataex
clear
input long InstitutionID str20 id float(pre_min pre_max post_min post_max)
1083 "30267930" 19194 19464 19644 19914
end
format %td pre_min
format %td pre_max
format %td post_min
format %td post_max
复制代码
* Example generated by -dataex-. To install: ssc install dataex