I importing many excel files with long variables names and lots of space. The truncated variable names do not work my purposes. So I need to shorten the labels into workable variable names.
I have gotten this code to work until the rename step, but I am not seeing the (probably very obvious error) in the rename step.
clear
set obs 2
gen ShelteredESHomelessPeoplein = 1
label variable ShelteredESHomelessPeoplein "Sheltered ES Homeless People in Families, 2007"
foreach v of varlist _all {
di "`v'"
local wholename : variable label `v'
di "`wholename'"
local new = substr(subinstr("`wholename'", " ", "",.),1,30)
di "`new'"
di "`v'" " " "`new'"
rename "`v'" " " "`new'"
}
Thanks in advance
Related Posts with Error with rename using local macros
margins at((mean) _all)Hi all, I am using the margins command to predict probabilities. I ran 5 separate logistic regressi…
3 slsHi everyone, I am quite new to use Stata for 3 stage least square. Please help! I would like to est…
Restructure Survival DatasetHi, I have survival data and I would like to change the structure of the dataset. stnum=patient id s…
How to compare two ivregress models with two independent samplesHi there, I want to compare two ivregress models with two independent samples. I am trying to see i…
r(198) errorI'm trying to use prior code to create a Turnip plot in STATA 11.2. I keep getting a r(198) error wh…
Subscribe to:
Post Comments (Atom)
0 Response to Error with rename using local macros
Post a Comment