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
Looping over correlation functionI am trying to produce a dataset that includes the autocorrelations of a variable (ret) across group…
-margins- after -xtlogit,fe-Dear Statalist This is a question about interpreting the results from a panel data fixed-effects lo…
ICD 10 to ICD-9 mapping using GEMsHi stata users, anybody has any experience in using GEMs files to map backwards from icd10 to ICD10 …
Loop over multiple arrays via foreachHello together! trying now since a few hours to fix my problem - I am not able to come up with an a…
Logit Regression Model / Plotting InteractionsHi everyone, I am working at my final paper and need some guidance. I want to look at the party id…
Subscribe to:
Post Comments (Atom)
0 Response to Replacing variable labels if same prefix, different suffix
Post a Comment