Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • forvalues loop for year by year PSM

    Hello!

    I'm doing a PSM using -psmatch2-. Instead of matching treatment and control firms once only in the sample period, I'm matching treatment and control firms once every year. Currently, I use the same set of variables to match treatment and control firms, and the code below can help me to achieve this. I wonder how this code can be revised so that I could use different sets of variables for different years to perform PSM? The sample period is 2010 to 2019. Thanks a lot for any suggestions.

    My code now for year by year PSM using the same matching variables each year
    Code:
    forvalues i = 2010(1)2019{
    preserve
    global XX employee asset age litigation ROA
    cap keep if year == `i'
    cap set seed 0001
    cap gen tmp = runiform()
    cap sort tmp
    psmatch2 y $XX i.industry i.year, out(performance) neighbor(2) caliper(0.05) common ties ate
    pstest $XX, both graph
    cap drop if _weight == .
    cap save `i'.dta, replace
    restore
    }
    
    
    use 2010.dta, clear
    
    forvalues i = 2011(1)2019{
    cap append using `i'.dta
    }
Working...
X