Dear Statalisters,

I am using Stata 16 on an Apple Macbook.

For my master thesis Financial Economics I need to apply propensity score matching. In short my thesis researches whether firms that have conducted security offerings perform better (or worse) than firms that have not conducted a security offering. I try to establish abnormal return in the five years post-issuance. It is an event study in which I want to match issuing firms with controlling firms/non-issuing firms in order to calculate abnormal return. My goal is to find an exact match on year and additionally I want to find a close match on Book-to-Market ratio and Market Value. I am not interested in the treatment effect of the match, but purely in the pair of firms.

I have two datasets:
1. The first dataset is the master dataset on firms that have issued securities (either equity or debt). The dataset contains 944 unique security offerings. I have already specified the event window so the entire dataset has 80280 observations with 69 variables. Since it is probably not necessary to post the entire dataset here, I have kept only the observations in the month prior the security offering.

2. The second dataset is regarding 6354 controlling firms that have not issued any securities. The entire dataset has 503,216 observations with 41 variables (It is a dataset with panel data). I have not yet specified the correct event window since I think I first need to match a controlling firm to an issuing firm and merge them consequently.

I used the append function in order to create a dataset with both issuing firms as well as controlling firms. Consequently, I generated a dummy variable called 'Treatment' to separate issuing firms from controlling firms. Next, I tried to write a syntax with a loop ('match within strata') in order to match on exact year and to find a close match on the Book-to-Market ratio and Market Value. However, If I try to do this, Stata gives the error 'R2000'. I have tried multiple things over the last week to find a solution, but I can't get the matching procedure to work. I am lost on how to proceed next and how to properly match issuing firms with non-issuing/controlling firms. I would highly appreciate it if someone could help me.

Below, you will find a sample of the master dataset (the issuing firms), a sample of the controlling firm dataset and an example of the syntax I used.

The master dataset:
* Example generated by -dataex-. To install: ssc install dataex
clear
input str30 Issuer double PERMNO float IssueDate str2 IssueType float(month2 MarketValue0_w BTMratio0_w returns_w)
"Rocky Mountain Chocolate Inc" 10044 13041 "FO" 427 47.49387 .12437394 -.006944
"Hanger Orthopedic Group Inc" 10051 11816 "FO" 387 52.407 .28022972 -.064935
"Hanger Orthopedic Group Inc" 10051 13726 "FO" 449 80.88525 .4946761 -.034965
"EnviroSource Inc" 10062 12228 "HY" 400 91.419 .7128496 0
"Oracle Corp" 10104 16811 "IG" 551 63028.32 .17509906 -.030952
"Oracle Corp" 10104 19284 "IG" 632 102669.13 .29079697 -.006003
"AlliedSignal Inc" 10145 13010 "IG" 426 13290.932 .2243635 .050562
"Honeywell International Inc" 10145 15273 "IG" 500 21426.66 .4530337 -.291465
"Tech Data Corp" 10182 12095 "FO" 396 437.625 .26288944 -.070248
"Tech Data Corp" 10182 19250 "IG" 631 1834.138 1.0916017 -.030339
"Fortune Brands Inc" 10225 16022 "IG" 525 9462.451 .28661707 .148018
"XOMA Corp" 10333 19058 "FO" 625 57.94474 .25905716 .086331
"Advanced Magnetics Inc" 10363 11722 "FO" 384 144.4575 .16932315 .072917
"ASARCO Inc" 10364 12085 "IG" 396 1113.0819 1.2195805 .075
"Astec Industries Inc" 10382 12212 "FO" 400 90.454 .3054702 .088889
"Watts Water Technologies Inc" 10606 16049 "FO" 526 401.0415 .7631879 .158221
"Theragenics Corp" 10644 13604 "FO" 445 282.05927 .06872669 -.094787
"HealthSouth Rehabilitation" 10693 12494 "HY" 409 854.733 .3429995 .044248
"HealthSouth Corp" 10693 19242 "HY" 631 2190.637 .26887158 .022321
"Fiserv Inc" 10696 19254 "IG" 631 9674.628 .3367571 .016826
"Cryenco Sciences Inc" 10714 11913 "FO" 390 28.74375 .034790173 .363636
"California Micro Devices Corp" 10785 16188 "FO" 530 285.47482 .07747794 -.008148
"Bethlehem Steel Corp" 10786 11904 "FO" 390 1062.0063 .6354011 -.082645
"CytRx Corp" 10838 19283 "FO" 632 77.34804 .3135697 -.071611
"Brunswick Corp" 10874 13488 "IG" 442 2509.6846 .4156299 .090426
"Unisys Corp" 10890 13423 "HY" 440 1062.0934 1.7514467 .042553
"Unisys Corp" 10890 17506 "HY" 574 1743.564 -.03682113 -.184211
"Pulitzer Publishing Co" 10929 12234 "FO" 400 66.61375 1.0069093 -.083665
"The Cato Corp" 11267 11807 "FO" 386 129.836 .23475 -.050847
"Sequent Computer Systems Inc" 11283 12095 "FO" 396 468.6437 .3680877 0
"Coca-Cola Co" 11308 19061 "IG" 625 102669.13 .2018944 .034503
"Proffitt's Inc" 11382 11710 "FO" 383 42.6375 .52076226 .022727
"Saks Inc" 11382 14187 "IG" 465 3224.494 .33945325 .013928
"Barr Laboratories Inc" 11415 15118 "FO" 495 2047.3735 .1378195 .013644
"MicroAge Inc" 11484 11745 "FO" 384 53.53 .6257613 .147727
"CONMED Corp" 11547 13223 "FO" 433 235.79 .3180881 -.055556
"Actuant Corp" 11581 19085 "HY" 626 1975.5236 .4651997 .029109
"Dana Corp" 11607 11842 "FO" 388 1700.9263 .6520359 -.017059
"Dana Corp" 11607 13949 "IG" 457 5730.263 .3237722 .093915
"Northland Cranberries Inc" 11614 11913 "FO" 390 29.279 .56812054 -.041667
end
format %td IssueDate
format %tm month2
[/CODE]

The dataset of controlling firms:
Code:
* Example generated by -dataex-. To install: ssc install dataex
clear
input str32 CompanyName double PERMNO float(month2 MarketValue0_w BTMratio0_w returns_w)
"WESTERN ENERGY RESOURCES INC" 10005 371   1.98198 .36175945        0
"WESTERN ENERGY RESOURCES INC" 10005 372   1.98198 .36175945  .464286
"WESTERN ENERGY RESOURCES INC" 10005 373   1.98198 .36175945        0
"WESTERN ENERGY RESOURCES INC" 10005 374   1.98198 .36175945        0
"WESTERN ENERGY RESOURCES INC" 10005 375   1.98198 .36175945        0
"WESTERN ENERGY RESOURCES INC" 10005 376   1.98198 .36175945        0
"WESTERN ENERGY RESOURCES INC" 10005 377   1.98198 .36175945  .464286
"FIGGIE INTERNATIONAL INC DEL" 10016 371 186.98625 1.8835983  .145833
"FIGGIE INTERNATIONAL INC DEL" 10016 372 180.18675 1.9546776 -.036364
"FIGGIE INTERNATIONAL INC DEL" 10016 373 207.38475 1.6983265  .160377
"FIGGIE INTERNATIONAL INC DEL" 10016 374     190.4 1.8498267 -.081967
"FIGGIE INTERNATIONAL INC DEL" 10016 375     207.4 1.6982015  .089286
"FIGGIE INTERNATIONAL INC DEL" 10016 376       221  1.593697   .07377
"FIGGIE INTERNATIONAL INC DEL" 10016 377  224.2845  1.570358  .015385
"FIGGIE INTERNATIONAL INC DEL" 10016 378 214.08975  1.645137 -.045455
"FIGGIE INTERNATIONAL INC DEL" 10016 379   217.488  1.619432   .02381
"FIGGIE INTERNATIONAL INC DEL" 10016 380    204.24  1.724476   -.0625
"FIGGIE INTERNATIONAL INC DEL" 10016 381    204.24  1.724476        0
"FIGGIE INTERNATIONAL INC DEL" 10016 382   190.624  1.847653 -.058333
"FIGGIE INTERNATIONAL INC DEL" 10016 383  180.1205  2.100766 -.053571
"FIGGIE INTERNATIONAL INC DEL" 10016 384   244.692  1.546397  .358491
"FIGGIE INTERNATIONAL INC DEL" 10016 385  268.4815 1.4093745  .104167
"FIGGIE INTERNATIONAL INC DEL" 10016 386 280.27313 1.3500794  .044304
"FIGGIE INTERNATIONAL INC DEL" 10016 387 268.38275  1.409893 -.042424
"FIGGIE INTERNATIONAL INC DEL" 10016 388 281.97174 1.3419465  .056962
"FIGGIE INTERNATIONAL INC DEL" 10016 389 247.59775  1.528249 -.120482
"FIGGIE INTERNATIONAL INC DEL" 10016 390 186.54625  2.028403 -.246575
"FIGGIE INTERNATIONAL INC DEL" 10016 391   203.505 1.8593695       .1
"FIGGIE INTERNATIONAL INC DEL" 10016 392   204.105 1.8539037        0
"FIGGIE INTERNATIONAL INC DEL" 10016 393  210.9085 1.7941003  .033333
"FIGGIE INTERNATIONAL INC DEL" 10016 394   231.319 1.6357973  .104839
"FIGGIE INTERNATIONAL INC DEL" 10016 395  227.2305  1.737531 -.014706
"FIGGIE INTERNATIONAL INC DEL" 10016 396  227.2305  1.737531        0
"FIGGIE INTERNATIONAL INC DEL" 10016 397   264.537 1.4924946  .171642
"FIGGIE INTERNATIONAL INC DEL" 10016 398   247.863  1.592896 -.051282
"FIGGIE INTERNATIONAL INC DEL" 10016 399   241.164 1.6371433 -.027027
"FIGGIE INTERNATIONAL INC DEL" 10016 400 229.44075  1.720793 -.041667
"FIGGIE INTERNATIONAL INC DEL" 10016 401 231.02925  1.708961  .007299
"FIGGIE INTERNATIONAL INC DEL" 10016 402 231.02925  1.708961        0
"FIGGIE INTERNATIONAL INC DEL" 10016 403 231.02925  1.708961  .007246
"FIGGIE INTERNATIONAL INC DEL" 10016 404   235.366 1.6774726 -.007246
"FIGGIE INTERNATIONAL INC DEL" 10016 405   209.596 1.8837192 -.109489
"FIGGIE INTERNATIONAL INC DEL" 10016 406   178.672 2.2097476 -.143607
"FIGGIE INTERNATIONAL INC DEL" 10016 407 187.35738 1.0870616  .048077
"FIGGIE INTERNATIONAL INC DEL" 10016 408 177.04413 1.1503855 -.055046
"FIGGIE INTERNATIONAL INC DEL" 10016 409 120.32125   1.69271 -.320388
"FIGGIE INTERNATIONAL INC DEL" 10016 410 131.89137  1.544218       .1
"FIGGIE INTERNATIONAL INC DEL" 10016 411 133.60425   1.52442  .012987
"FIGGIE INTERNATIONAL INC DEL" 10016 412 149.02013 1.3667215  .115385
"FIGGIE INTERNATIONAL INC DEL" 10016 413 139.30988 1.4619855 -.068966
"FIGGIE INTERNATIONAL INC DEL" 10016 414 135.87013 1.4989977 -.024691
"FIGGIE INTERNATIONAL INC DEL" 10016 415 124.69094 1.6333905 -.082278
"FIGGIE INTERNATIONAL INC DEL" 10016 416 119.58625  1.703114 -.034483
"FIGGIE INTERNATIONAL INC DEL" 10016 417 104.21088  1.954393 -.128571
"FIGGIE INTERNATIONAL INC DEL" 10016 418  93.96062 2.1675994 -.098361
"FIGGIE INTERNATIONAL INC DEL" 10016 419  83.88187  .7775458 -.109091
"FIGGIE INTERNATIONAL INC DEL" 10016 420  94.15312  .6927227  .122449
"FIGGIE INTERNATIONAL INC DEL" 10016 421 114.69563  .5686529  .218182
"FIGGIE INTERNATIONAL INC DEL" 10016 422   122.922  .5305967  .074627
"FIGGIE INTERNATIONAL INC DEL" 10016 423 117.80025 .55366606 -.041667
"FIGGIE INTERNATIONAL INC DEL" 10016 424 110.11762  .5922939 -.065217
"FIGGIE INTERNATIONAL INC DEL" 10016 425 117.38625  .5556187  .069767
"FIGGIE INTERNATIONAL INC DEL" 10016 426 138.37837  .4713309  .173913
"FIGGIE INTERNATIONAL INC DEL" 10016 427 175.96263 .37065825  .271605
"FIGGIE INTERNATIONAL INC DEL" 10016 428 180.87575  .3605901  .029126
"FIGGIE INTERNATIONAL INC DEL" 10016 429   163.812 .39815155  -.09434
"FIGGIE INTERNATIONAL INC DEL" 10016 430 158.69287  .4109952  -.03125
"FIGGIE INTERNATIONAL INC DEL" 10016 431 141.62912   .350161 -.107527
"FIGGIE INTERNATIONAL INC DEL" 10016 432 151.86737  .3265547  .072289
"FIGGIE INTERNATIONAL INC DEL" 10016 433  168.9311 .29356936   .11236
"FIGGIE INTERNATIONAL INC DEL" 10016 434   184.518 .26877052  .090909
"FIGGIE INTERNATIONAL INC DEL" 10016 435   181.101 .27384165 -.018519
"FIGGIE INTERNATIONAL INC DEL" 10016 436  199.8945 .24809586  .103774
"FIGGIE INTERNATIONAL INC DEL" 10016 437 206.15375 .24056317  .034188
"FIGGIE INTERNATIONAL INC DEL" 10016 438 168.67125 .29402164 -.181818
"FIGGIE INTERNATIONAL INC DEL" 10016 439   184.005 .26951984  .090909
"FIGGIE INTERNATIONAL INC DEL" 10016 440  183.1397  .2707933  -.00463
"FIGGIE INTERNATIONAL INC DEL" 10016 441 144.80812  .3424739 -.209302
"FIGGIE INTERNATIONAL INC DEL" 10016 442 172.91794 .28680077  .194118
"FIGGIE INTERNATIONAL INC DEL" 10016 443    164.34  .4533833 -.054187
"FIGGIE INTERNATIONAL INC DEL" 10016 444 169.47563  .4396443   .03125
"FIGGIE INTERNATIONAL INC DEL" 10016 445    164.34  .4533833 -.030303
"FIGGIE INTERNATIONAL INC DEL" 10016 446 165.71237  .4496285  .010417
"FIGGIE INTERNATIONAL INC DEL" 10016 447 162.29562 .45909435 -.020619
"FIGGIE INTERNATIONAL INC DEL" 10016 448  169.1291  .4405451  .042105
"FIGGIE INTERNATIONAL INC DEL" 10016 449 188.14125  .3960269  .111111
"FIGGIE INTERNATIONAL INC DEL" 10016 450 194.98276 .38213125  .036364
"FIGGIE INTERNATIONAL INC DEL" 10016 451   191.562   .388955 -.017544
"FIGGIE INTERNATIONAL INC DEL" 10016 452   202.429 .36807474  .053571
"FIGGIE INTERNATIONAL INC DEL" 10016 453  183.5585  .4059142  -.09322
"FIGGIE INTERNATIONAL INC DEL" 10016 454   188.705  .3948438  .028037
"FIGGIE INTERNATIONAL INC DEL" 10016 455 180.19313  .3973292 -.045455
"FIGGIE INTERNATIONAL INC DEL" 10016 456 181.90926 .39358085  .009524
"FIGGIE INTERNATIONAL INC DEL" 10016 457 175.04475  .4090154 -.037736
"FIGGIE INTERNATIONAL INC DEL" 10016 458  191.5305  .3738099  .088235
"FIGGIE INTERNATIONAL INC DEL" 10016 459 187.21675   .382423 -.022523
"SCOTT TECHNOLOGIES INC"       10016 460   203.609  .3516348  .087558
"SCOTT TECHNOLOGIES INC"       10016 461  202.4685  .3536155 -.008475
"SCOTT TECHNOLOGIES INC"       10016 462  199.0075  .3597653 -.017094
"SCOTT TECHNOLOGIES INC"       10016 463   179.972  .3978174 -.095652
end
format %tm month2
The syntax I tried to use
Code:
 
use "/Users/larsvanrooijen/Documents/Studie/Master Financial Economics EUR/Master Thesis Financial Economics/Data/Data on issuing firms/Stata .dta  final files/mergedfinaldatasetanalysis.dta", clear
keep if dif == 1
append using "/Users/larsvanrooijen/Documents/Studie/Master Financial Economics EUR/Master Thesis Financial Economics/Data/Data on benchmark firms/Merged control firm dataset.dta", force
gen Treatment = 0
replace Treatment = 1 if IssueType == "FO" | IssueType == "IG" | IssueType == "HY"
gen fyear = year(date2)
        g att = .
        egen matchyear = group(fyear)
        levels matchyear, local(gr)
        qui foreach j of local gr {
        psmatch2 Treatment BTMratio0_w MarketValue0_w if matchyear==`j', noreplacement neighbor(1) common logit
        replace att = r(att) if  matchyear==`j'
        }
gen pair = _id if _treated==0
replace pair = _n1 if _treated==1

In addition, but maybe unnecessary: the '_w' in the variables is because I have winsorized the most important variables to control for large outliers.

I hope I have specified my question sufficiently and that someone can help me, because I am rather lost.
Many thanks in advance!!

Best,
Lars