Announcement

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

  • psmatch2: no observation error

    Dear All,

    I am trying to run the code using psmatch2 but I am always having an error. I thought that this could be because of some variables that are string but that was not the case.
    Below I show you the code I use, the error message, and the data ex.
    Could anyone suggest something, please?

    -----------------------------------------------------------------------------------------------------------------------------------------------
    The data:

    Code:
    * Example generated by -dataex-. To install: ssc install dataex
    clear
    input int year float(dep_var V5 treatment_var V4 V7 V10 V9 V6 V11 V2 V8 V1 sector)
    1994    .7082309 29 1 5  2.187361   .0295588         0 10.956755  5.583496 15.255788 1 . 10
    1998           . 50 1 5         .  .07696104 .26236427 11.175395  5.645447         . 0 0  8
    1990           . 18 0 2 4.4043837          0         0  10.61892 3.4011974  15.33874 0 . 10
    1991   .04993898 19 0 2 4.2286706          .         0 10.480118 3.4011974 15.163027 0 . 10
    1992    .0909944 20 . 2 4.0422206          .         0 10.411294  3.496508  15.08939 0 . 10
    1993 -.035919093 21 . 2  4.224259          .         0 10.585856  3.295837 15.010067 0 . 10
    1994  -.09820418 22 0 2 4.2318325          0         0 10.645897  3.178054 14.913176 0 . 10
    1990           . 18 0 3 3.0271034  .00995033         0 11.213012 4.0943446 14.739928 0 . 10
    1991           . 19 0 3  3.115209          .         0 10.985867 4.2195077 14.828034 0 . 10
    1992           . 20 . 3   3.44056          .         0 11.103452 4.0073333   14.9451 0 . 10
    1993           . 21 . 3  3.362049          .         0  10.80608  4.060443 14.902356 0 . 10
    1994           . 22 0 3  3.286006 .019802626         0  10.95433 4.0775375 14.848474 0 . 10
    1995           . 23 . 3 3.2693825          .         0  11.13285  4.060443  14.81307 0 . 10
    1996           . 24 . 3  3.293813          .         0 11.076535 4.0430512 14.820108 0 . 10
    1997           . 25 . 3 2.9964695          .         0 10.933935  4.317488     14.82 0 . 10
    1998           . 26 0 3  2.917372  .00995033         0 11.055813 4.3820267 14.791044 0 0 10
    1999   .14697023 27 . 3 3.0414534          .         0 11.523808 4.2195077 14.749254 0 0 10
    2000           . 28 . 3  3.556708          .         0 11.166665 3.9318256 14.981294 0 0 10
    2001    .1962552 29 . 3  3.548383          .         0 11.350946   3.89182 14.929615 0 0 10
    2002   .25624016 30 0 3  3.399654  .04879016         0 11.229283 4.0073333  14.89584 0 0 10
    2003   .04284711 31 . 3  3.225606          .         0 11.374087  4.060443 14.765348 0 0 10
    2004   .14136788 32 . 3  3.271253          .         0  11.34552 4.0253515  14.77816 0 0 10
    2005   .19424163 33 . 3  3.200689          .         0 11.068303 4.0430512  14.72304 0 0 10
    2006   .19701327 34 0 3  3.097219   .0295588         0  10.08209 4.0943446 14.674246 0 0 10
    2007   .29603934 35 . 3  3.131885          .         0  10.99834 4.0943446   14.7044 0 0 10
    2008   .27086148 36 . 3  2.997099          .         0 11.060678 4.1271343 14.599006 0 0 10
    2009  -.05040929 37 . 3     3.277          .         0 10.704953  3.871201   14.5476 0 0 10
    2010    .1271988 38 0 3  3.207995 .019802626         0 10.526127 3.8501475 14.515752 0 0 10
    2011           . 39 . 3  3.207838          .         0  10.40058  3.871201  14.53028 0 0 10
    2012     .154523 40 . 3  3.266607          .         0 10.294938    3.7612  14.47905 0 0 10
    2013           . 41 . 3  3.317735          .         0 10.123064  3.637586 14.406563 0 0 10
    2014   .11801518 42 0 3  3.637851  .06765865         0 10.302308  3.465736  14.55483 0 0 10
    1990           . 28 0 5  4.091702 .019802626         0 10.414456  5.476463 17.006052 0 . 13
    1991   .07999235 29 0 5 3.9284005          .         0 10.238552  5.442418  16.84275 0 . 13
    1992   .02206246 30 . 5 4.0215883          .         0  10.23418  5.327876 16.762228 0 . 13
    1993    .3271044 31 . 5  3.906087          .         0  10.66261  5.236442 16.663305 0 . 13
    1994    .3943854 32 0 5   3.81493  .03922071         0 10.623963  5.192957 16.564837 0 . 13
    1990           . 35 0 5         .  .03922071  .4054651  11.63811  5.488938         . 0 . 16
    1990           . 32 0 5         .          0         0  10.98486  5.921578         . 0 . 11
    1991           . 33 0 5         .          .         0 10.863417  5.869297         . 0 . 11
    1992           . 34 . 5  4.954209          .         0 10.877573  5.777652 18.241745 0 . 11
    1993           . 35 . 5         .          .         0  10.57481  5.771441 18.148026 0 . 11
    1994           . 36 0 5  4.829414          0         0 10.898678  5.743003 18.067959 0 . 11
    1990           .  1 0 2         .          0         0  9.693244  3.178054         . 0 . 13
    1990           .  2 0 1         .  .07696104         0  9.803989  2.484907         . 0 . 13
    1998    .7837098 41 1 5   3.80878  .03922071  .8754687  11.44629  5.476463 16.772978 0 1 13
    1990           .  7 0 2   2.73308          0         0 10.553288  3.178054  13.39269 0 . 13
    1991           .  8 . 2  2.794196          .         0 10.602625  3.178054 13.453806 0 . 13
    1992           .  9 . 2  3.152299          .         0 10.611092  3.218876 13.856105 0 . 13
    1993           . 10 . 2 3.5069315          .         0 10.737732  3.218876 14.206236 0 . 13
    1994           . 11 . 2  3.426021          0         0 10.541604 3.2580965 14.164546 0 . 13
    1995           . 12 . 2  3.284977          .         0 10.386684  3.367296 14.136642 0 . 13
    1996           . 13 . 2  3.204017          .         0  10.17241 3.4011974 14.089583 0 . 13
    1997           . 14 . 2 3.2368796          .         0 10.654108  3.367296 14.086294 0 . 13
    1998           . 15 . 2 3.2109044  .03922071         0 10.978704  3.367296  14.06032 0 0 13
    1999           . 16 . 2  3.111067          .         0  10.58192  3.465736 14.056103 0 0 13
    1998     1.53622 10 1 1 4.6014156  .03922071 1.1314021 11.255802    3.7612  15.84135 1 0 13
    1998   1.3039737 44 1 6  4.626701  .09531018  .5877867 10.778122   5.56452  17.67165 0 0 13
    1990           . 17 0 1  3.332483          0         0 10.473296  2.833213 13.597833 0 . 10
    1991  -.06139006 18 0 1   3.19189          .         0 10.592299  2.772589  13.45724 0 . 10
    1992  .073225066 19 . 1  3.172358          .         0 10.573125  2.772589  13.43268 0 . 10
    1993  .072842985 20 . 1  3.060701          .         0 10.529494  2.833213 13.383327 0 . 10
    1994   .11625186 21 0 1  3.067874          0         0  10.56288  2.890372  13.44542 0 . 10
    1995   .23837173 22 . 1   3.00287          .         0 10.613914 3.0445225  13.53176 0 . 10
    1996    .0949664 23 . 1  3.386194          .         0 10.900625  2.995732 13.823833 0 . 10
    1997    .1695384 24 . 1  3.789418          .         0  10.88429 3.0910425  14.36258 0 . 10
    1998    .2088548 25 0 1  3.771528          0         0 10.996078  3.135494 14.386886 0 0 10
    1999    .2217206 26 . 1  3.798376          .         0 10.804995  3.218876  14.49429 0 0 10
    2000   .23127405 27 . 1  3.770002          .         0 10.951507 3.2580965 14.502303 0 0 10
    2001    .1807457 28 . 1 3.8084834          .         0  10.97691 3.2580965 14.535664 0 0 10
    2002   .15723252 29 0 1  3.793439  .03922071         0 10.947026 3.2580965 14.515472 0 0 10
    2003  .074203104 30 . 1 3.7149494          .         0 10.826777 3.4011974  14.57491 0 0 10
    2004   .06009637 31 . 1  3.648937          .         0 10.922874 3.4011974 14.508897 0 0 10
    2005    .1386071 32 . 1  3.607474          .         0 10.802596 3.4011974 14.467434 0 0 10
    2006     .172186 33 0 1  3.561847   .0295588         0  10.87656 3.4011974 14.421807 0 0 10
    2007    .2544822 34 . 1  3.594459          .         0 10.819793  3.367296 14.420518 0 0 10
    2008   .23618452 35 . 1  3.872919          .         0 10.846828 3.4011974  14.73288 0 0 10
    2009  -.05430889 36 . 1 4.0838094          .  .4700036 10.311878  3.367296 14.666346 0 0 10
    2010   -.3312848 37 0 1 4.3687863          0         0 10.476178  3.367296  14.60093 0 0 10
    2011   .13715614 38 . 1  3.786725          .         0   10.6596  3.295837 14.541325 0 0 10
    2012   .11435942 39 . 1   3.80094          .         0 10.535173 3.2580965 14.480214 0 0 10
    2013    .3088551 40 . 1    3.8578          .         0 10.700254  3.295837   14.5664 0 0 10
    2014    .3230887 41 0 1  3.820939  .03922071         0 10.774525 3.2580965 14.537798 0 0 10
    2015           . 42 . 1  3.809893          .         0 10.742653  3.218876 14.487532 0 0 10
    2016           . 43 . 1 3.5674164          .         0 10.569715 3.5263605  14.55254 0 0 10
    2017           . 44 . 1         .   .6931472         0 10.734845 3.5263605         . 0 0 10
    1990           .  6 0 4 1.2881228          0         0  8.631407 4.5849676 13.175477 0 . 16
    1991   -2.632504  7 0 4 1.4961182          .         0  9.111107 4.4188404 13.383472 0 . 16
    1992           .  8 . 4 -1.636606          . .09531018  9.148261 4.2195077 10.037043 0 . 16
    1994   1.5621703 19 1 5  4.925325  .09531018 .18232156 11.528597  5.817111 18.223991 0 .  2
    1990           . 53 0 4  3.007244  .04879016         0  9.835975  4.727388 15.157354 0 .  4
    1991           . 54 0 4   2.92913          .         0 10.050314  4.691348  15.07924 0 .  4
    1992    .4784346 55 . 4 3.0777285          .         0 10.772307   4.65396 14.985867 0 .  4
    1993           . 56 . 4  2.789717          .         0  8.062454 4.6051702 14.887648 0 .  4
    1994           . 57 0 4 3.8048904  .00995033         0  8.874398  4.356709 15.395055 0 .  4
    1995           . 58 . 4 4.1990757          .         0  9.960611  3.637586 15.332204 0 .  4
    1996   1.1467034 59 . 4   4.04103          .         0  10.12066    3.7612 15.283786 0 .  4
    1997   1.2473873 60 . 4  3.984344          .         .  10.26416    3.7612 15.218613 0 .  4
    1998   1.1229415 61 0 4 4.1651387 .019802626         0 10.428835 3.8066626  15.44487 0 0  4
    1999   1.0039082 62 . 4 4.1256313          .  .9162908  10.14658   3.78419  15.38289 0 0  4
    end

    -----------------------------------------------------------------------------------------------------------------------------------------------
    The code:
    Code:
    foreach num of numlist 1(1)16 {
    use data1_pscor, clear
    keep if sector==`num'
    psmatch2 treatment_var V1 V2 V4 V5 V6 V7 V8 V9 V10 V11 i.year , out(dep_var)  common
    sort corp year
    save data2_pscor`num', replace
    }
    -----------------------------------------------------------------------------------------------------------------------------------------------
    The error:
    Code:
     psmatch2: |   psmatch2: Common
     Treatment |        support
    assignment | Off suppo  On suppor |     Total
    -----------+----------------------+----------
     Untreated |         0        565 |       565
       Treated |         1         41 |        42
    -----------+----------------------+----------
         Total |         1        606 |       607
    
    file data_pscor4.dta saved
    (26,051 observations deleted)
    no observations
    r(2000);
    
    end of do-file
    
    r(2000);





  • #2
    It looks like there are no observations with sector == 5 (or possibly other other number if you omitted some lines of output). You can check this guess with
    Code:
    tabulate sector
    .
    David Radwin
    Senior Researcher, California Competes
    californiacompetes.org
    Pronouns: He/Him

    Comment


    • #3
      there are no observations with sector equal to 5. try,
      Code:
      levelsof sector, local(levels)
      foreach l of local levels {
      use data1_pscor, clear
      keep if sector==`l'
      psmatch2 treatment_var V1 V2 V4 V5 V6 V7 V8 V9 V10 V11 i.year, out(dep_var) common
      sort corp year
      save data2_pscor`l', replace    
      }
      Last edited by Øyvind Snilsberg; 14 Apr 2022, 12:04. Reason: crossed with #2

      Comment


      • #4
        Dear David, Dear Oyvind,
        Thanks for your help. It worked out very well!

        Best
        wishes
        Jade

        Comment


        • #5
          Originally posted by Øyvind Snilsberg View Post
          there are no observations with sector equal to 5. try,
          Code:
          levelsof sector, local(levels)
          foreach l of local levels {
          use data1_pscor, clear
          keep if sector==`l'
          psmatch2 treatment_var V1 V2 V4 V5 V6 V7 V8 V9 V10 V11 i.year, out(dep_var) common
          sort corp year
          save data2_pscor`l', replace
          }
          Kindly Sir guide us that how we will do PSM based on some specific variables such as firm size or leverage etc.
          regards
          Sattar Khan

          Comment


          • #6
            Hi Sattar,

            If I understood your question well, I would say that you just need to change the list of variables in your code. For example, replace V1...Vn with the variables you want (firm size for example). But in my case, it was giving me an error because in some sectors I had no obs. What I did was that I just redefined and reclassified the sectors in my data and that worked out well.

            Best
            JLi

            Comment

            Working...
            X