Announcement

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

  • Matching through different SIC codes

    Hello you all,

    I am currently working on an assignment were I want to match a group of companies doing an IPO to a control group by industry and market cap.

    For the industry I need to match on SIC codes, the problem now is that not every treated company has a control company with the same 3-digit SIC code.
    I am trying to make an algorithm (a loop) which will first look at the 3-digit SIC code, but when there is no match, it should look at the 2-digit SIC code. And when
    there is no match on the 2-digit SIC code, looks on the 1-digit SIC code. But i haven't found the right algorithm at this moment.

    I know that I need to merge the two groups of companies and use:

    merge 1:M 3SICCODE using control group
    keep if _merge ==3

    But before or after this there needs to be a line where it will search for another match of a 2-digit SIC code or even a 1-digit SIC code. Because it could also be possible that
    the _merge is 1(treated group) or 2(control group), so there is no match.

    Maybe someone of you can help me?

    Many thanks


  • #2
    Boy:
    welcome to the list.
    I'm not clear whether your data are sparsed in different datasets (as it would seem from -merge-) or not.
    If you have access to a unique dataset (or you can create somehow), you can create different groups of companies for further analyses,as in the following toy-example (I created a variable named -IPO- which takes on 0 if the company was not involved in an IPO and 1 otherwise):
    Code:
    . set obs 10
    number of observations (_N) was 0, now 10
    
    . g SIC_CODE=10001 in 1/5
    (5 missing values generated)
    
    . replace SIC_CODE=10002 if SIC_CODE==.
    (5 real changes made)
    
    . g IPO=1 in 1/2
    (8 missing values generated)
    
    . replace IPO=0 in 3/7
    (5 real changes made)
    
    . replace IPO=1 if IPO==.
    (3 real changes made)
    
    . egen flag=group( SIC_CODE IPO)
    Kind regards,
    Carlo
    (Stata 18.0 SE)

    Comment

    Working...
    X