Dear Members of Statalist,

this is my first post here in this forum. First of all, I am using Stata 13 for my data analysis.

I found similar questions in Statalist, but unfortunately, these topics could not help me.

For my data analysis, I want to use propensity score matching to match observations within my dataset. My intention is not to implement a regression or ATE directly but to have a paired data set to work with and make additional changes. I used the following
Code:
  psmatch2 DiD, pscore(prob) outcome(Cred) caliper(0.001) noreplace neighbor(1)

bysort id (_treated): drop if missing(_treated[1]) | missing(_treated[_N])

gen pair = _id if _treated == 0

replace pair = _n1 if _treated == 1

bysort pair: egen paircount = count(pair)

drop if paircount != 2

save Data, replace
I have estimated the propensity scores manually using a logit model and called the propensity scores "prob".
This code works. However, each time I execute my do file, the number of pairs changes. Sometimes there 648 observations and then 680 etc. This is a big problem since I want my results to be reproducible. In other topics, the answer was to use some randomly distributed identifier together with set seed like

Code:
set seed 12345
  
gen double rand = runiform()
  
sort rand
Unfortunately, this leads to a change in the number of matched observations, but the number of observations varies each time I execute my code...


If anything is missing to answer my question, please let me know.
If you could help me with this problem, it would be a great help!