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
How can I learn to write Ado fileHello Sir, I want to write ado files to modify "tab" command so that I can get the desired output p…
Control for country effect in a pooled estimationHello everybody, I have panel data with two time periods (t=2) and n regions as entities. I am cons…
categorical outcome for first occuring eventDear stalisters, I am performing an event history analysis using a multinomial model (competing ris…
using loop for saving and directoryHello, I try to use the loop for my analysis and save them and draw charts. so I receive an error se…
reshape data wide to long I am working on wide formatted data that have 11574 observations &11547 row. the repeated obser…
Subscribe to:
Post Comments (Atom)
0 Response to Renaming columns
Post a Comment