I have multiple sheets of excel that I import one by one into Stata. Each of the sheets has about 150 variables. The suffix of the variables is always either *_dum or *_yr. In Stata, I want to keep the label of *_dum, and the value of *_yr.
Regardless of the number of variables and the specific prefixes in each sheet, I want to create a code that will replace the variable label of those that end with "_yr" by the label in "_dum", if they have the same prefix. Prefixes will vary depending on the Excel input.
For instance 7_2_2_1_dum label needs to replace 7_2_2_1_yr label. Having both the label and the value that I want in 7_2_2_1_yr, I can now drop 7_2_2_1_dum.
Thank you.
Related Posts with Replacing variable labels if same prefix, different suffix
Interpreting a 3-category dummy variables and interaction termsDear All, I run the following model: Suppose I have a dummy variable: small, medium, large; and the…
help with krlsHello, I'm using the krls command to predict a binary outcome (whether the patient starts dialysis …
Create a new variable with random probability and with probabilityI have to create 2 variables the first one is a random variable (e1) between 1-17 the second is a v…
Repeated time values - Panel DataHi, I have election data for a country. I am trying to set a panel but as each place has multiple c…
"rangestat" with "excludeself" and "interval(t -1 0)"Dear Statalisters, I have a question about the results after the rangestat command. Suppose I inpu…
Subscribe to:
Post Comments (Atom)
0 Response to Replacing variable labels if same prefix, different suffix
Post a Comment