Announcement

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

  • How to save/create data subsets or frames from a loop, so these frames or subsets can be merged?

    Dear Stata community,

    My question in short: does anyone know how to create a loop which automatically creates new unique subsets or frames (which I want to merge later on)?

    For my thesis I use a Difference in Difference method with propensity score matching to test the effect (ATET) of an acquisition by a Private Equity firm on operational performance of target companies. I use propensity score matching based on industry and year of acquisition to find similar control companies.
    To estimate the ATET I need to create multiple subsets/frames to calculate the propensity scores of all industries in corresponding acquisition years.
    As I have 109 treatment companies, I want to create a loop that will save each subset or frame as a distinct name based on industry group and companynumber

    For example: a frame is created with name "frame1(1)" and another "frame3(4)"

    -> So, the first number corresponds to the industry number and the (number) corresponds to the number of the company within the industry
    -> frame1(1) = frame of industry 1 of company 1 within industry 1
    -> frame 3(4) = frame of industry 3 of company 4 within industry 3

    As I do not know how to use a more simplistic Stata command/code to estimate the ATET with propensity score matching, I was wondering if anybody could help me solve this problem?

    Kind regards,
    Roger

  • #2
    frame names need to be legal Stata names, so no parentheses and they cannot begin with a number. Secondly, there is a restriction on the number of frames allowed. For my Stata SE, this is 100 but there may be a way to increase this. The following using the Grunfeld dataset puts each observation into a distinct frame.

    Code:
    webuse grunfeld
    forval company= 1/5{
        forval time=1/10{
            frame put * if company==`company' & time==`time', into(c`company'_t`time')
        }
    }
    
    *RANDOM CHECK
    
    frame change c3_t5
    l
    Res.:

    Code:
    .
    . *RANDOM CHECK
    
    .
    . frame change c3_t5
    
    .
    . l
    
         +--------------------------------------------------+
         | company   year   invest   mvalue   kstock   time |
         |--------------------------------------------------|
      1. |       3   1939     48.1   2256.2    172.6      5 |
         +--------------------------------------------------+

    Comment

    Working...
    X