Announcement

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

  • Creating all possible firmpairs within each industry

    Dear Statalist,

    The following shows a snippet of the dataset used:

    HTML Code:
    compid    compname    industry_classification    industryid    compid_in_industry    sum_count_compid    abnormal_msreturn    abnormal_annual_volatility    abnormal_volume    msreturn    cv_ptb    cv_lev
    ym    compid    compname    industry_classification    industryid    compid_in_industry    sum_count_compid    abnormal_msreturn    abnormal_annual_volatility    abnormal_volume    msreturn    cv_ptb    cv_lev
    2022m11    18    Autoneum Holding Ag    Automobiles & Auto Parts    2    1    4    .2524526    -.0041824    -3495.858    .2121214    .2945096    1.783716
    2022m12    18    Autoneum Holding Ag    Automobiles & Auto Parts    2    1    4    -.0972508    .0076708    -5521.412    -.1206896    .3644247    1.783716
    2023m1    18    Autoneum Holding Ag    Automobiles & Auto Parts    2    1    4    .2284532    -.0018746    1843.499    .1960784    .3242081    1.783716
    2023m2    18    Autoneum Holding Ag    Automobiles & Auto Parts    2    1    4    .1438912    -.0053739    -1763.732    .1180329    .3761804    1.783716
    2017m5    63    Daetwyler Holding Ag    Automobiles & Auto Parts    2    2    4    -.0426654    .0043835    1811.052    -.0225652    2.558055    .2189781
    2017m6    63    Daetwyler Holding Ag    Automobiles & Auto Parts    2    2    4    -.0323213    .0015906    -470.6808    -.0115432    2.496325    .2189781
    2017m7    63    Daetwyler Holding Ag    Automobiles & Auto Parts    2    2    4    -.0442455    -.0005095    -8111.853    -.0282728    2.314436    .2013656
    2017m8    63    Daetwyler Holding Ag    Automobiles & Auto Parts    2    2    4    -.061213    .0040422    -2662.163    -.0493361    2.239011    .2013656
    The intention is to do a regression analysis where:
    - the dependent variable(s) is(are) abnormal_msreutrn, or abnormal_annual_volatility, or abnormal_volume
    - the independent variables are msreturn, cv_ptb, cv_lev
    - additionally include firm- and year-fixed-effects based on industry.

    In order to apply the analysis, the dataset needs to be extended by all possible firmpair combinations for each specific industry.
    Example given: If industryid == 2, the following firmpairs need to be generated: (1,2), (1,3), (1,4), (2,1), (3,1), (4,1). Firmpair (1,1) should be neglected. Please note, that the numbers mentioned in brackets address the variable compid_in_industry.

    Explanation of the variables prevalent in the dataset:
    • compid: unique company identifier over the entire dataset
    • industryid: unique industry identifier over the entire dataset
    • compid_in_industry: unique company identifier in each industry
    • sum_count_compid: the sum of distinct companies prevalent in the respecting industry
    By already reading several posts about generating all possible pairs based on group and id, I could not manage to handle it for my dataset.
    How can the expected dataset be achieved?

    Best,
    Rob

  • #2
    I don't understand what you want. I grasp that firm pair (1,1) should be neglected: it's self-pairing which might be out of the scope of your study. But I do not grasp why you want (1,2), (1,3), (1,4), (2,1), (3,1), and (4,1) but not (2, 3), (2, 4), (3, 2), (3, 4), (4, 2), and (4, 3). The rule seems to be pair everything with firm id 1 (except itself). Is that right? Firm 1 is in some way special and privileged among firms for your purposes? Does every industry have a compid_in_industry = 1? If not, how do we know which firm is special?

    When you post back, please also use the -dataex- command to show example data. The table you show, in addition to being hard to read, is very difficult to import into Stata. It appears to be a copy/paste from the data editor. But that's not really workable. In order to check whatever solution they propose, those who want to help you will need a workable example of your data. That is what the -dataex- command is for. If you are running version 18, 17, 16 or a fully updated version 15.1 or 14.2, -dataex- is already part of your official Stata installation. If not, run -ssc install dataex- to get it. Either way, run -help dataex- to read the simple instructions for using it. -dataex- will save you time; it is easier and quicker than typing out tables. It includes complete information about aspects of the data that are often critical to answering your question but cannot be seen from tabular displays or screenshots. It also makes it possible for those who want to help you to create a faithful representation of your example to try out their code, which in turn makes it more likely that their answer will actually work in your data.

    Comment


    • #3
      Dear Clyde,

      Thanks for the quick reply.
      My apologies for the unclear wording and the not-workable example of my data.

      You are right about the firm pairs. It was incorrectly explained by me. What my example of firm pairs showed was all possible firm pairs of compid == 1 in industry xy. However, as you have correctly understood, my intention is to form all possible firm pairs within an industry. Accordingly, as you have already noticed, the total number of firm pairs within industry == 2 are (1,2), (1,3), (1,4), (2,1), (3,1), (4,1), (2,3), (2,4), (3,2), (4,2), (3,4) and (4,3). The firm pairs (1,1), (2,2), (3,3), and (4,4) are neglected because self-pairing is outside the scope of the study. Having said this, it is not the case that compid_in_industry == 1 is privileged. All firms in each industry are equal. I assume that the conclusion drawn here follows the incorrect formulation of my previous example.

      Please find below a working example of my data via -dataex-.

      Code:
      * Example generated by -dataex-. For more info, type help dataex
      clear
      input float(ym compid abnormal_msreturn msreturn cv_ptb cv_lev) str50 industry_classification byte(industryid compid_in_industry) float sum_count_compid
      688  16    -.004668593     .021276474    2.438172    .1722365 "Communications & Networking"            10  1  3
      689  16   -.0036844015     .020833254     2.38803    .1722365 "Communications & Networking"            10  1  3
      690  16     -.04108071     -.02295929    2.469511    .1722365 "Communications & Networking"            10  1  3
      691  16     -.03600639    -.023498654   3.0622704   .12608159 "Communications & Networking"            10  1  3
      692  16      .12981665      .13903737    3.022397   .12608159 "Communications & Networking"            10  1  3
      693  16      .05446744         .07277   3.3892314   .12608159 "Communications & Networking"            10  1  3
      694  16     .011924505     .028446317    3.612522   .12608159 "Communications & Networking"            10  1  3
      695  16      .05556607      .07234037    3.748091   .12608159 "Communications & Networking"            10  1  3
      696  16     -.05864644     -.04365075   4.0511284   .12608159 "Communications & Networking"            10  1  3
      697  16    -.013648868    -.004149437     3.89961   .12608159 "Communications & Networking"            10  1  3
      698  16     -.15533996      -.1541666    3.593948   .12608159 "Communications & Networking"            10  1  3
      699  16    -.016082585     -.01773405    3.234553   .12608159 "Communications & Networking"            10  1  3
      700  16     .004906535     .003008962    3.210593   .12608159 "Communications & Networking"            10  1  3
      701  16     -.09435046     -.10000002    3.210593   .12608159 "Communications & Networking"            10  1  3
      702  16     .010251045 -1.1920929e-07    2.815675    .2166065 "Communications & Networking"            10  1  3
      703  16      .06957567      .06111133    2.803147    .2166065 "Communications & Networking"            10  1  3
      704  16      .04228044       .0450263    2.991068    .2166065 "Communications & Networking"            10  1  3
      705  16     -.18773955      -.1943888    3.069368    .2166065 "Communications & Networking"            10  1  3
      706  16     -.08510518     -.09452748    2.477418    .2166065 "Communications & Networking"            10  1  3
      707  16     -.05589765     -.06730777   2.2550457    .2166065 "Communications & Networking"            10  1  3
      708  16     -.04669803     -.06185579    2.020145    .2166065 "Communications & Networking"            10  1  3
      709  16     .010949373              0   1.9418448    .2166065 "Communications & Networking"            10  1  3
      710  16      .05153859      .04709566    1.998221    .2166065 "Communications & Networking"            10  1  3
      711  16     .035930872      .04047966   2.1458097    .2166065 "Communications & Networking"            10  1  3
      712  16     -.07193351     -.07348704   2.2053285    .2166065 "Communications & Networking"            10  1  3
      713  16   -.0039119124    -.006220877   2.0079765    .2166065 "Communications & Networking"            10  1  3
      714  16     .012673974     .017214417   2.0361698    .2166065 "Communications & Networking"            10  1  3
      715  16     -.21864223     -.22153836    2.130709    .2403846 "Communications & Networking"            10  1  3
      716  16      .04047632     .021739125   1.6301405    .2403846 "Communications & Networking"            10  1  3
      717  16    -.036376774     -.05512571    1.696005    .2403846 "Communications & Networking"            10  1  3
      718  16      .02802086      .02149391    1.620261    .2403846 "Communications & Networking"            10  1  3
      719  16      .05648077      .05410826   1.6334338    .2403846 "Communications & Networking"            10  1  3
      720  16     -.09180093     -.09030414   1.7882148    .2403846 "Communications & Networking"            10  1  3
      721  16     -.11779332     -.12330168    1.590622    .2403846 "Communications & Networking"            10  1  3
      722  16      -.3248492      -.3504171    1.360097    .2403846 "Communications & Networking"            10  1  3
      723  16       .3764682       .3321103    .9818249    .2403846 "Communications & Networking"            10  1  3
      724  16    -.022099495     -.04820943   1.1564447    .2403846 "Communications & Networking"            10  1  3
      725  16      .27905977      .25325608   1.1432658    .2403846 "Communications & Networking"            10  1  3
      726  16      .20456123      .18937624   1.4612057    .2403846 "Communications & Networking"            10  1  3
      727  16      .17340446       .1747575   1.7434853    .6329114 "Communications & Networking"            10  1  3
      728  16       .0485189      .05619848    2.069339    .6329114 "Communications & Networking"            10  1  3
      729  16     -.14588386     -.14084506   2.1298068    .6329114 "Communications & Networking"            10  1  3
      730  16      .11554182      .11839688    1.837546    .6329114 "Communications & Networking"            10  1  3
      731  16      .06415784       .0667752   2.1163695    .6329114 "Communications & Networking"            10  1  3
      732  16      .16110253      .16793895   2.2003524    .6329114 "Communications & Networking"            10  1  3
      733  16    -.070266664     -.05620921    2.610189    .6329114 "Communications & Networking"            10  1  3
      734  16     -.04077435     .006925106    2.532925    .6329114 "Communications & Networking"            10  1  3
      735  16     -.05493033    -.016506076    2.453294    .6329114 "Communications & Networking"            10  1  3
      736  16      .03847992      .06992996   2.4398515    .6329114 "Communications & Networking"            10  1  3
      737  16     -.03116536   -.0013073683    2.577639    .6329114 "Communications & Networking"            10  1  3
      738  16    -.005596995     .017015696    2.621328    .6329114 "Communications & Networking"            10  1  3
      739  16     -.08188266    -.063063085   2.7894015   .26722926 "Communications & Networking"            10  1  3
      740  16   -.0039837956     .015110016    2.651172   .26722926 "Communications & Networking"            10  1  3
      741  16     -.05658078       -.037889    2.569652   .26722926 "Communications & Networking"            10  1  3
      742  16     -.17896587      -.1603375    2.484588   .26722926 "Communications & Networking"            10  1  3
      743  16     -.02485484    -.015075207    2.162052   .26722926 "Communications & Networking"            10  1  3
      744  16      .02234435      .02551043    2.123064   .26722926 "Communications & Networking"            10  1  3
      745  16     -.13353789     -.13598686   2.1159754   .26722926 "Communications & Networking"            10  1  3
      746  16     .006157637    -.003838837   1.8607825   .26722926 "Communications & Networking"            10  1  3
      747  16      -.1519531     -.16281313    1.811231   .26722926 "Communications & Networking"            10  1  3
      748  16     -.09766233     -.11392415    1.472733   .26722926 "Communications & Networking"            10  1  3
      749  16     -.10529667     -.12727267    1.444377   .26722926 "Communications & Networking"            10  1  3
      750  16      .13077831      .09970248   1.1909465   .26722926 "Communications & Networking"            10  1  3
      751  16     -.12004745     -.14479011    1.345855           0 "Communications & Networking"            10  1  3
      752  16    -.021280646     -.05696213    1.148044           0 "Communications & Networking"            10  1  3
      753  16      .07382333      .03355682   1.0962803           0 "Communications & Networking"            10  1  3
      754  16       .3144729      .27110386   1.1720772           0 "Communications & Networking"            10  1  3
      755  16     -.03010607     -.05108571   1.4549285           0 "Communications & Networking"            10  1  3
      756  16      .10321653       .0861373   1.3976188           0 "Communications & Networking"            10  1  3
      757  16         .13088      .12019813   1.4937513           0 "Communications & Networking"            10  1  3
      688  66   -.0002336502     .025806427   2.3007424   .12217706 "Communications & Networking"            10  2  3
      689  66     -.07039839     -.04745579   2.3179913   .12217706 "Communications & Networking"            10  2  3
      690  66     .015672803        .034814   2.2290928   .12217706 "Communications & Networking"            10  2  3
      691  66    -.009935617    .0029001236   2.3020692   .12217706 "Communications & Networking"            10  2  3
      692  66      .13300717      .14227879   2.3976016   .12217706 "Communications & Networking"            10  2  3
      693  66     -.01760894  -.00050622225    2.625377   .12217706 "Communications & Networking"            10  2  3
      694  66     -.07194549     -.05673748   2.6174414   .12217706 "Communications & Networking"            10  2  3
      695  66     -.04056996    -.025241613    2.446825   .12217706 "Communications & Networking"            10  2  3
      696  66     -.07100302      -.0561983   2.4018564   .12217706 "Communications & Networking"            10  2  3
      697  66     .004354477      .01401043   1.8754294    4.699885 "Communications & Networking"            10  2  3
      698  66      -.1405009     -.13932067   1.8480748    4.699885 "Communications & Networking"            10  2  3
      699  66     .031827927     .030100226   1.6084487    4.699885 "Communications & Networking"            10  2  3
      700  66    .0018872023  1.1920929e-07    1.699266    4.699885 "Communications & Networking"            10  2  3
      701  66     -.09239858     -.09805185   1.7342798    4.699885 "Communications & Networking"            10  2  3
      702  66     -.07627553     -.08567315    1.495748    4.699885 "Communications & Networking"            10  2  3
      703  66      .08018684     .071653605   1.4104017    4.699885 "Communications & Networking"            10  2  3
      704  66      .08384776      .08670115   1.5001247    4.699885 "Communications & Networking"            10  2  3
      705  66    -.008840561    -.016903222    1.639582    4.699885 "Communications & Networking"            10  2  3
      706  66     -.00838536    -.018569529   1.5990037    4.699885 "Communications & Networking"            10  2  3
      707  66     -.15863675     -.16888565   1.5957135    4.699885 "Communications & Networking"            10  2  3
      708  66      .12054217      .10286689   1.3083754    4.699885 "Communications & Networking"            10  2  3
      709  66    -.023037255     -.03363931   1.3772287    4.848502 "Communications & Networking"            10  2  3
      710  66      .13291669      .12816453    1.350825    4.848502 "Communications & Networking"            10  2  3
      711  66      .07384038       .0785414   1.5451577    4.848502 "Communications & Networking"            10  2  3
      712  66     -.09704947     -.09882945   1.6370434    4.848502 "Communications & Networking"            10  2  3
      713  66      .02286148     .020923495   1.4289804    4.848502 "Communications & Networking"            10  2  3
      714  66      .02683842     .031802297   1.5419892    4.848502 "Communications & Networking"            10  2  3
      715  66      -.0811143      -.0856163   1.4891814    4.848502 "Communications & Networking"            10  2  3
      716  66     -.01790744     -.03595507    1.400464    4.848502 "Communications & Networking"            10  2  3
      717  66   .00034463406     -.01864815   1.3446202    4.848502 "Communications & Networking"            10  2  3
      718  66      .07866251      .07205069    1.347757    4.848502 "Communications & Networking"            10  2  3
      719  66     .024496555       .0228951   1.4219935    4.848502 "Communications & Networking"            10  2  3
      720  66     -.12574178     -.12490976    1.455452    4.848502 "Communications & Networking"            10  2  3
      721  66     -.04814982     -.05445528   1.3256773   3.9155645 "Communications & Networking"            10  2  3
      722  66     -.22037047     -.24921465    1.274648   3.9155645 "Communications & Networking"            10  2  3
      723  66      .15947115      .12180388     .949363   3.9155645 "Communications & Networking"            10  2  3
      724  66       .1504469       .1199751   1.0032152   3.9155645 "Communications & Networking"            10  2  3
      725  66     -.02446097     -.04440331    1.209504   3.9155645 "Communications & Networking"            10  2  3
      726  66    .0011223555    -.011616886    1.124817   3.9155645 "Communications & Networking"            10  2  3
      727  66      .14266825      .14397621   1.1421888   3.9155645 "Communications & Networking"            10  2  3
      728  66       -.150117     -.14383566   1.2355616   3.9155645 "Communications & Networking"            10  2  3
      729  66      -.1626231     -.15759993   1.0805724   3.9155645 "Communications & Networking"            10  2  3
      730  66       .2069571      .20963907    .9394577   3.9155645 "Communications & Networking"            10  2  3
      731  66    -.016379476     -.01373905   1.0964695   3.9155645 "Communications & Networking"            10  2  3
      732  66      .05809844      .06368148   1.1106246   3.9155645 "Communications & Networking"            10  2  3
      733  66      .01946473      .03461194    1.200999   3.9155645 "Communications & Networking"            10  2  3
      734  66      .11394656      .16726935    1.214065   3.9155645 "Communications & Networking"            10  2  3
      735  66     -.10757881    -.070488036   1.3959026   3.9155645 "Communications & Networking"            10  2  3
      736  66    .0035676956     .034166694   1.3164167   3.9155645 "Communications & Networking"            10  2  3
      737  66    -.014385343     .016115904   1.3414602   3.9155645 "Communications & Networking"            10  2  3
      738  66     -.02877408     -.00634402   1.3730367   3.9155645 "Communications & Networking"            10  2  3
      739  66      .03295219      .05426991    1.365415   3.9155645 "Communications & Networking"            10  2  3
      740  66     .008695483     .028009176   1.4456395   3.9155645 "Communications & Networking"            10  2  3
      741  66     -.01948744   -.0007364154    1.467477   3.9155645 "Communications & Networking"            10  2  3
      742  66      -.1865412     -.16728073    1.517703   3.9155645 "Communications & Networking"            10  2  3
      743  66      .05772388      .06814182   1.2556536   3.9155645 "Communications & Networking"            10  2  3
      744  66     -.12850225     -.12510365   1.3466344    3.266988 "Communications & Networking"            10  2  3
      745  66     -.03529358     -.03787887   1.1905675    3.266988 "Communications & Networking"            10  2  3
      746  66     -.05610603     -.06535411   1.1281408    3.266988 "Communications & Networking"            10  2  3
      747  66     -.02954161     -.04170179   1.0489925    3.266988 "Communications & Networking"            10  2  3
      748  66      .03925455      .02087903    .9954839    3.266988 "Communications & Networking"            10  2  3
      749  66     -.08128184     -.10333675   1.0088611    3.266988 "Communications & Networking"            10  2  3
      750  66      .11614025      .08523405    .9297128    3.266988 "Communications & Networking"            10  2  3
      751  66     -.06711495     -.09292042    .9965987    3.266988 "Communications & Networking"            10  2  3
      752  66      -.1491887     -.18170726    .8569988    3.266988 "Communications & Networking"            10  2  3
      753  66    -.015071929     -.05216092     .748617    3.266988 "Communications & Networking"            10  2  3
      754  66      .08482409      .04874206    .7028061    3.266988 "Communications & Networking"            10  2  3
      755  66       .0373522     .014992356    .7709637    3.266988 "Communications & Networking"            10  2  3
      756  66      .14321685      .12555408    .7733721    4.675489 "Communications & Networking"            10  2  3
      757  66      .10758615      .09711301    .8456703    4.675489 "Communications & Networking"            10  2  3
      688  95    -.007217407      .01865673    1.699551           0 "Communications & Networking"            10  3  3
      689  95     .025360465      .05054951   1.7270436           0 "Communications & Networking"            10  3  3
      690  95     -.05621022     -.03835422   1.7982748           0 "Communications & Networking"            10  3  3
      691  95      -.1861269     -.17548943   1.9096968           0 "Communications & Networking"            10  3  3
      692  95     .035483718      .04397535   1.5681362           0 "Communications & Networking"            10  3  3
      693  95      -.1057831     -.09014338   1.6428094           0 "Communications & Networking"            10  3  3
      694  95     -.04251909     -.02685189   1.4920802           0 "Communications & Networking"            10  3  3
      695  95     -.04756552    -.032350183    1.451978           0 "Communications & Networking"            10  3  3
      696  95      .05119824     .067846656    1.432618           0 "Communications & Networking"            10  3  3
      697  95   -.0004104376     .009207964   1.5155884           0 "Communications & Networking"            10  3  3
      698  95    -.012283146    -.010948777   1.4879316           0 "Communications & Networking"            10  3  3
      699  95      .05157161      .04981518   1.4580712           0 "Communications & Networking"            10  3  3
      700  95       .0864042      .08435881   1.5825745           0 "Communications & Networking"            10  3  3
      701  95    -.013308227    -.019448876    1.737512           0 "Communications & Networking"            10  3  3
      702  95     .001906991    -.008264482   1.6489762           0 "Communications & Networking"            10  3  3
      703  95       .2498611            .24   1.5652944           0 "Communications & Networking"            10  3  3
      704  95    -.016045451    -.013440788    1.906813           0 "Communications & Networking"            10  3  3
      705  95     -.05224305     -.05994558   1.8887023           0 "Communications & Networking"            10  3  3
      706  95     .035239697      .02463758    1.728292           0 "Communications & Networking"            10  3  3
      707  95      -.0622046    -.073550105    1.836957           0 "Communications & Networking"            10  3  3
      708  95       .1896893      .17099214   1.7257047           0 "Communications & Networking"            10  3  3
      709  95      .01490116     .003911495   1.9611458           0 "Communications & Networking"            10  3  3
      710  95     -.06225806    -.066233635   2.0154781           0 "Communications & Networking"            10  3  3
      711  95      .12720561      .13212836   1.9269664           0 "Communications & Networking"            10  3  3
      712  95     -.05096239     -.05282545   2.0925045           0 "Communications & Networking"            10  3  3
      713  95      .06816435      .06614792   2.0097353           0 "Communications & Networking"            10  3  3
      714  95     -.03872639     -.03406316   2.1597543           0 "Communications & Networking"            10  3  3
      715  95      -.1975574      -.2015114   1.9892976           0 "Communications & Networking"            10  3  3
      716  95     .031542063     .012618065   1.5899216           0 "Communications & Networking"            10  3  3
      717  95      .04155505     .021806955   1.6076154           0 "Communications & Networking"            10  3  3
      718  95      .04758394      .04115844    1.653114           0 "Communications & Networking"            10  3  3
      719  95      .12619054       .1244508   1.6960847           0 "Communications & Networking"            10  3  3
      720  95     -.06338221     -.06250018   1.9336884           0 "Communications & Networking"            10  3  3
      721  95     -.10096467     -.10694426   1.8426913           0 "Communications & Networking"            10  3  3
      722  95    -.020011485     -.05754286   1.6455308           0 "Communications & Networking"            10  3  3
      723  95      .05561602      .02145231   1.4382597           0 "Communications & Networking"            10  3  3
      724  95      .09482193      .06623602    1.520044           0 "Communications & Networking"            10  3  3
      725  95      .02990484       .0090909   1.7072042           0 "Communications & Networking"            10  3  3
      726  95      .07649064     .063063025   1.6869706           0 "Communications & Networking"            10  3  3
      727  95    -.014972568    -.012711763    1.874131           0 "Communications & Networking"            10  3  3
      728  95    -.017042816    -.010014534    1.803722  .002386574 "Communications & Networking"            10  3  3
      729  95     -.04993689     -.04479766   1.8089125  .002386574 "Communications & Networking"            10  3  3
      730  95       .1147629      .11800277     1.73884  .002386574 "Communications & Networking"            10  3  3
      731  95     -.05628997     -.05412716   1.9179145  .002386574 "Communications & Networking"            10  3  3
      732  95      .04312599      .05007136    1.858223  .002386574 "Communications & Networking"            10  3  3
      733  95     -.05928797     -.04495913    1.923105  .002386574 "Communications & Networking"            10  3  3
      734  95    -.006538391      .04422247   1.8556278  .002386574 "Communications & Networking"            10  3  3
      735  95     -.03833103 -1.1920929e-07   1.9186536  .002386574 "Communications & Networking"            10  3  3
      736  95     -.03870118     -.00956279   1.8849018  .002386574 "Communications & Networking"            10  3  3
      737  95        .045313      .07724118   1.8849018  .002386574 "Communications & Networking"            10  3  3
      738  95     -.03450817    -.012803972   1.9991384  .002386574 "Communications & Networking"            10  3  3
      739  95      .04390085      .06485081    2.030571 .0010738712 "Communications & Networking"            10  3  3
      740  95     -.13607132     -.11936647    2.196278 .0010738712 "Communications & Networking"            10  3  3
      741  95      .10353303      .12586462    1.962184 .0010738712 "Communications & Networking"            10  3  3
      742  95    -.015042841     .006142497    2.156824 .0010738712 "Communications & Networking"            10  3  3
      743  95      .05164409      .06227124   2.1883872 .0010738712 "Communications & Networking"            10  3  3
      744  95      -.0380562    -.035632193   2.2804468 .0010738712 "Communications & Networking"            10  3  3
      745  95      .05797684      .05482721   2.2278414 .0010738712 "Communications & Networking"            10  3  3
      746  95    -.010317504     -.02033907   2.2646651 .0010738712 "Communications & Networking"            10  3  3
      747  95     .003691554    -.009227216   2.2402015 .0010738712 "Communications & Networking"            10  3  3
      748  95    -.013469398    -.031431913    2.198475 .0010738712 "Communications & Networking"            10  3  3
      749  95      -.0606305      -.0841347   2.1671798 .0010738712 "Communications & Networking"            10  3  3
      750  95      .15071595      .11942255   1.9741938 .0010738712 "Communications & Networking"            10  3  3
      751  95    -.016454518     -.04454881   1.9688398           0 "Communications & Networking"            10  3  3
      752  95    .0026147366      -.0355829    1.797435           0 "Communications & Networking"            10  3  3
      753  95      .17896855      .13485992    1.839128           0 "Communications & Networking"            10  3  3
      754  95     .008465767     -.02354264   2.0429606           0 "Communications & Networking"            10  3  3
      755  95     .013035893    -.009184718   2.0475934           0 "Communications & Networking"            10  3  3
      756  95      .03013003     .015063763   2.0336957           0 "Communications & Networking"            10  3  3
      757  95     -.00967574     -.01826483   2.0313795           0 "Communications & Networking"            10  3  3
      end
      format %tm ym
      Best,
      Rob

      Comment


      • #4
        Code:
        preserve
        ds industryid, not
        rename (`r(varlist)') =2
        tempfile copy
        save `copy'
        
        restore
        joinby industryid using `copy'
        drop if compid_in_industry == compid_in_industry2
        Note: with a large data set this is going to be slow at the -joinby- step. Be patient.

        The more serious problem is that it is also possible that you will exhaust available memory at the -joinby- step. If that happens you will have to break your data set into chunks, each chunk consisting of all the observations of some subset of the industries, and process each one separately. Then append those partial results all together and you're done.

        Comment


        • #5
          Dear Clyde,

          Sorry for the late response but it worked perfectly. Thank you!

          Best,
          Rob

          Comment

          Working...
          X