Hi all,
I want to create a variable that generates the difference between certain variables between observations which are matched according to nearest neighbor matching with the psmatch2 command. Let me elaborate using my data as an example.
Every observation is unique by id and the variable n1 tels with which other observation the current observation is matched. So the first line has ID 1 and tels that the matched observation is the observation with the ID 20. Now I want to generate a variable that creates the difference between variables of the matched observation (in my case gmean_growt_06, at_2000 capr1_2006). So for example here I would like to get the difference for my variable between ID1 and ID20 and then do this for all my observations.
I hope this explains it clear enough. I anybody can help me it would really help me out!
Thanks in advance!
Kind regards,
Timme Ariens
I want to create a variable that generates the difference between certain variables between observations which are matched according to nearest neighbor matching with the psmatch2 command. Let me elaborate using my data as an example.
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input str8 tic float(gmean_growt_06 gmean_growt_15 at_2000 log_at_2009 capr1_2006 dummy_capr) double _gmean_growt_15 int(_id _n1) "INDB" 5.478975 8.245689 1949.976 3.651474 11.05 1 12.39554214477539 1 20 "FRME" 7.331064 7.096053 1621.063 3.65137 9.2 0 12.39554214477539 2 20 "COLB" 10.708447 18.69658 1496.495 3.505276 12.21 1 12.39554214477539 3 20 "PACW" 27.281605 25.984386 358.287 3.7262444 10.94 1 12.39554214477539 4 20 "GBCI" 18.297142 6.606849 1056.712 3.7918165 12.1 1 12.39554214477539 5 20 "STBA" 4.2745175 7.169137 2310.29 3.6201856 9.68 0 12.39554214477539 6 20 "NBTB" 8.114316 7.135749 2655.788 3.737513 10.42 1 12.39554214477539 7 20 "CBU" 6.977745 7.956045 2022.635 3.73262 14.22 1 12.39554214477539 8 20 "BANR" 11.480777 12.932588 1982.831 3.6741464 9.53 0 12.39554214477539 9 20 "BANF" 5.146177 7.175343 2570.255 3.64504 13.72 1 12.39554214477539 10 20 "RNST" 18.052546 13.843563 1211.94 3.5612304 11.31 0 12.39554214477539 11 20 "WSBC" 5.586751 7.800224 2310.137 3.732181 12.35 0 12.39554214477539 12 20 "CHFC" 1.50907 13.71022 1973.424 3.6284616 16.2 0 12.39554214477539 13 20 "SRCE" 2.812696 2.2404406 3182.181 3.6572566 12.91 1 12.39554214477539 14 20 "CVBF" 18.187893 2.1808996 2307.996 3.828645 12.3 1 16.421262741088867 15 21 "FFBC" -3.003677 3.362188 3932.512 3.8248494 11.28 0 16.421262741088867 16 21 "BPFH" 33.386032 3.745403 921.51 3.7817025 10.7 0 .20106756687164307 17 22 "WABC" 3.076864 .637506 4031.381 3.696837 9.77 0 .20106756687164307 18 22 "FCF" 7.50561 .3093964 4372.312 3.80931 11.5 0 8.277576446533203 19 25 "FNB" -4.057727 12.395542 3886.548 3.939972 9.9 1 7.135749340057373 20 7 "PB" 25.9576 16.421263 703.073 3.946963 13.52 0 2.1808996200561523 21 15 "NPBC" 17.522005 .20106757 2512.508 3.9769874 9.77 0 3.745403289794922 22 17 "HWC" 10.690675 17.458748 3013.43 3.939374 12.46 0 .6375060081481934 23 18 "PRK" 5.318968 .6315439 3211.068 3.847593 14.72 0 .6375060081481934 24 18 "UBSI" 3.7757785 8.277576 4904.547 3.8923786 10 0 .3093963861465454 25 19 "FMBI" 8.998436 3.9577024 5906.484 3.887092 9.56 0 .3093963861465454 26 19 "TRMK" 5.492141 4.880563 6886.988 3.9789114 9.6 0 .3093963861465454 27 19 "ONB" -4.0437613 6.96684 8767.748 3.9033794 11.12 1 .3093963861465454 28 19 end
I hope this explains it clear enough. I anybody can help me it would really help me out!
Thanks in advance!
Kind regards,
Timme Ariens
Comment