Dear all,
I am new to Stata and currently in the process of cleaning my data / coding variables.
I have come across two issues and would appreciate your guidance:
(1) Renaming variables according to a key
I have ~300 variables which are to be renamed according to a key in an Excel file. The key specifies the current name of the variable (string), the new name and a label for the variable.
Is there a way to automatically rename and label all variables according to the key (without having to manually enter the rename command and new name for each variable)?
(2) Generating new variables according to key
I have a variable called "Industry" which specifies industry segments on a very granular level and would like to generate a new variable for industry which subsumes industry segments into higher level categories. Again, I have a key that specifies how industry segments are subsumed. What would be the command to generate a new variable based on this key?
Example:
Many thanks in advance for your help!
I am new to Stata and currently in the process of cleaning my data / coding variables.
I have come across two issues and would appreciate your guidance:
(1) Renaming variables according to a key
I have ~300 variables which are to be renamed according to a key in an Excel file. The key specifies the current name of the variable (string), the new name and a label for the variable.
Is there a way to automatically rename and label all variables according to the key (without having to manually enter the rename command and new name for each variable)?
(2) Generating new variables according to key
I have a variable called "Industry" which specifies industry segments on a very granular level and would like to generate a new variable for industry which subsumes industry segments into higher level categories. Again, I have a key that specifies how industry segments are subsumed. What would be the command to generate a new variable based on this key?
Example:
Current category | New category |
Retail banking | Financial services |
Investment banking | Financial services |
Investment advisory | Financial services |
Many thanks in advance for your help!
Comment