Hi there,
I was wondering if anybody could help. I have 200+ columns that could change when new data is incorporated. I would like to rename the columns with the variable labels (unique for each column) however when I attempt to use the following I come across a syntax error due to the fact that some labels contain illegal characters:
foreach v of varlist del* {
**find out distinct value (level) of del variables
levelsof `v'
** store the values (from the results) into a string local tmp
local tmp `r(levels)'
** rename the keep variables by the string local tmp
rename `v' `tmp'
}
Is there a way to rename the variables within the loop but also automatically ignore illegal characters or shorten labels when required?
Kind Regards,
Hannah
Related Posts with Renaming columns
Rangestat SEHello Guys, I'm trying to run a rolling time-series regression using mata and rangestat. The code t…
Variables not working togetherHello, I am relatively new to Stata and I am trying to run a regression and my whitedummy variable …
wrapping up using lines of codes in a loopHi, How can I wrap up the below code in a loop? Best, Nader gen n=_n gen sample=_n replace sam…
Plot predictions after xthregHello Statalist, I have experimental panel data und used xthreg to estimate a threshold function (w…
ttest result and asdoc table not agree.Hi all, I am getting problem with results in asdoc table, p-values in the Word file not agree with …
Subscribe to:
Post Comments (Atom)
0 Response to Renaming columns
Post a Comment