Hi,
I have a long list of dummy variables (more than 2000) [these are tags for companies which I converted to 1/0 dummies] for each firm - notes as t1-t2100
In a separate file I have a matrix that converts that split these t* dummies into categories such as software, hardware:
I want to create a variable in the original dataset using this category matrix such that basically
gen software==1 if t30==1 | t31==1| t32==1 ......
But doing it for so many category and t* variables is very tedious - I am sure there is a neat way to do it rather than manually putting it like above?
Would appreciate any help or suggestion.
To clarify the legend matrix which I copied above is in a separate data file than the main data which looks like this:
I want to create additional columns to this dataset so that based on the categories matrix above new variables will be soft=0/1 if if t30==1 | t31==1| t32==1 ......
Thanks
I have a long list of dummy variables (more than 2000) [these are tags for companies which I converted to 1/0 dummies] for each firm - notes as t1-t2100
In a separate file I have a matrix that converts that split these t* dummies into categories such as software, hardware:
tag_m | tagss | soft | hard | bio | OTHER | MEDICAL | telcomobile | ECOMMERCE | CYBER | FINTECH | INDUSTRY4 | AGRI |
t6 | 3d-technology | 1 | ||||||||||
t30 | adtech | 1 | ||||||||||
t31 | advertisers | 1 | ||||||||||
t32 | advertising | 1 | ||||||||||
t46 | agriculture | 1 | ||||||||||
t48 | agtech | 1 | ||||||||||
t59 | alert-system | 1 | 1 | |||||||||
t63 | algorithms | 1 | ||||||||||
t74 | analytics | 1 | ||||||||||
t87 | anti-fraud | 1 | 1 |
gen software==1 if t30==1 | t31==1| t32==1 ......
But doing it for so many category and t* variables is very tedious - I am sure there is a neat way to do it rather than manually putting it like above?
Would appreciate any help or suggestion.
To clarify the legend matrix which I copied above is in a separate data file than the main data which looks like this:
company_id | value | amount | age | t1 | t2 | t3 | t4 | t5 | t6 | t7 | t8 | t9 | t10 | t11 |
x | 100 | 10 | 4 | 0 | 1 | 1 | 1 | 0 | 0 | 0 | 1 | 1 | 0 | 0 |
y | 4000 | 4 | 8 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 1 |
company_id | value | amount | age | t1 | t2 | t3 | t4 | t5 | t6 | t7 | t8 | t9 | t10 | t11 | soft | hard | bio | other |
x | 100 | 10 | 4 | 0 | 1 | 1 | 1 | 0 | 0 | 0 | 1 | 1 | 0 | 0 | ||||
y | 4000 | 4 | 8 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 1 |
Comment