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
Panel Data Regression and ANOVAHi, I am using panel data for US manufacturing companies for the period 2000-19. I am focusing on t…
Event StudyDear all, to perform my event study, I need not merge to datasets based on an identifier ID and mul…
Find value starting with a pattern ( similar to LIKE operator in SQL)Hello ALL, I am new to Stata, I have a small doubt, Any Help would be greatly appreciated. TABLE1(…
Between subjects error term for three-way repeated measures anovaI have been having some difficulties trying to run a three-way, repeated measures anova. I have made…
Regression Discontinuity DesignDear all, I am planning on using the regression discontinuity design for the purpose of my research…
Subscribe to:
Post Comments (Atom)
0 Response to Error with rename using local macros
Post a Comment