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
Bug in -svy: mean- ?I have a bit of code that looks like this: Code: qui { putexcel set test.xlsx, replace us…
Weighting European Social SurveyHello everyone, Does anyone here know when to use each weight in the European Social Survey? I'm us…
How to keep first record but drop missing in longHI all, I have a dataset in long-format and would like to drop information so that I can just keep …
Difficiculties with predicting GDPHi, I am writing my bachelor's thesis right now, and I am having difficulties with the predict comma…
Omitted values while doing regression with fixed effectsStatalist forum, I am trying to do 4 regression models with fixed effects. However, when I run the …
Subscribe to:
Post Comments (Atom)
0 Response to Replacing variable labels if same prefix, different suffix
Post a Comment