Hello all!

I am trying to combine the psmatch2 command with exact matching. More specifically, I am trying to adapt the code given in "help psmatch2" so as to only get a pscore for each observation (I estimate the ATT later taking a differences-in-differences approach).

Below is the code provided in Stata:

Matching within strata

The following code illustrates how to match within exact cells and then calculate the average effect for the whole population.

g att = .
egen g = group(groupvars)
levels g, local(gr)
qui foreach j of local gr {
psmatch2 treatvar varlist if g==`j', out(outvar)
replace att = r(att) if g==`j'
}
sum att





and below is what I immediately thought of doing:

global psmlist x y z
probit treatvar $psmlist
predict double p, pr
g p2=p

egen g=group(groupvars)
levels g, local (gr)
qui foreach j of local gr {
psmatch2 treatvar $psmlist if g==`j', pscore(p2) caliper (0.01) norepl common
replace p2 = r(p2) if g==`j'
}


which yields the exact same result as for the predicted p variable (which doesn't include exact matching). I also do not get any of the usual variables that comes with psmatch2 (i.e. _id, _n1 etc)

Clearly I don't fully understand the original code. Can someone help me out, please?

PS: I have already estimated p2 using the code detailed here: https://www.stata.com/statalist/arch.../msg00073.html , but my supervisor recommended that I try to modify the officially given code instead.

Many thanks!
Melanie