Announcement

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

  • test code for creating 852 dummy variables from five categorical variables and label list

    Hello Statalisters!

    I am working with a dataset that I am setting up for network analysis. I have 300 (firm) cases and five variables (invest) that capture the top five investors for each case. These five variables (invest) have 852 unique investors. I need to make 852 dummy variables to capture whether or not a case (firm) received money from a particular investor.

    I have a list of the top five investors in a company in variables invest1-invest5.

    I need to identify a procedure to create a series of dummy variables for the 852 category classification of the investors in order to conduct network analysis. So basically a 1 or 0 for each investor. Is there any way to use the label list created for the variable to generate the dummy variables? I am kind of stuck here on the most efficient way to do this. This is the first time I have encountered such an issue with so many dummies to create, and after searching the forums, I could not find any previous posts with a similar question to mine. Any advice on how to proceed would be helpful.

    I am using Stata 18. I have an annotated example of my data structure or the five variables I am attempting to create 852 dummy variables.


    Code:
    * Example generated by -dataex-. For more info, type help dataex
    clear
    input int(invest1 invest2 invest3 invest4 invest5)
    716   3 249 469 614
    812   9 430 118 543
    688  11 566 142 651
    688  11  61 399 576
    833  11 547 399 583
    749  16 213  36 558
    711  17 401 335 340
    797  18 171 277 404
    .
    .
    .
    end
    label values invest1 invest
    label values invest2 invest
    label values invest3 invest
    label values invest4 invest
    label values invest5 invest
    label def invest 683 "500 Global", modify
    label def invest 685 "Abstract Ventures", modify
    label def invest 688 "Alchemist Accelerator", modify
    label def invest 689 "Alumni Ventures", modify
    label def invest 691 "Andreessen Horowitz", modify
    label def invest 694 "Atlassian", modify
    label def invest 705 "Brad Nordholm", modify
    label def invest 706 "CSC Upshot", modify
    label def invest 708 "CanopyBoulder", modify
    label def invest 711 "CircleUp", modify
    label def invest 712 "Citi", modify
    Thank you in advance for your time and consideration.
Working...
X