【use 鏁版嵁1,clear
drop if treat==1 & year!=eventyear //鍙瀵瑰熀鏈熻繘琛屽尮閰
g match=0 if treat==1 //鐢ㄤ簬璁板綍浣跨敤鐨勬帶鍒剁粍鏍锋湰鍏鍙+骞?
g matchmark=. //鐢ㄤ簬璁板綍鏄鍚﹀尮閰嶆垚鍔
g matched=. //鐢ㄤ簬璁板綍浣跨敤杩囩殑鎺у埗缁勬牱鏈鍏鍙革紝涓嬩竴骞撮厤瀵逛笉鍐嶄娇鐢?
g q_matchyear=. //鐢ㄤ簬璁板綍鍖归厤骞翠唤
forval j=2003/2017{
2. psmatch2 treat lnofdi itr agdpv lnlf al ei nrr ind if year==`j' & matched!=1, norepl n(1
> ) cal(0.005)
3. replace match=1 if treat==0 & _weight!=.
4. replace matchmark=_n1 if _treat==1
5. replace q_matchyear=year if _weight!=.
6. g a=EXPY if _treat==0 & _weight!=.
7. bys EXPY:egen b=min(a)
8. replace matched=1 if b!=.
9. drop a b
10. }
outcome does not vary; remember:
0 = negative outcome,
all other nonmissing values = positive outcome
r(2000);