I have an imported dataset where I need to rename all of the variables and want to use the imported label as a part of the new name of the variables. The general idea of what I want to do is the following:
foreach var of varlist _all {
local varlabel : variable label `var'
local strN = "str" + `varlabel'
rename `var' `strN', if...
However, 'varlabel' is a number for each variable and so does not concactenate as it is an integer. To my knowledge Tostring would not work in this situation, and if it does I have been unable to figure out how. Any help on how to change the type of a local variable would be much appreciated. I've been scouring the internet for the past couple of hours to no success.
Related Posts with Changing Type of Local Variables
Creating Dummy Variables from List of Drug NamesI have a list of over 500 drug names, and I'm trying to write a loop to create a dummy variable for …
Help: Multiple constraints for clogitHi, I was wondering if someone could help with defining multiple constraint using clogit. I have St…
Generate Leads and LagsI would like to create leads and lags to control for the last two years before a pollical leader cam…
Loops: Creating Dummy Variables from List of Drug NamesI have a list of over 500 drug names, and I'm trying to write a loop to create a dummy variable for …
Default option for marginsHello, i am using the margins command to predict the effect of some variables, this is my regression…
Subscribe to:
Post Comments (Atom)
0 Response to Changing Type of Local Variables
Post a Comment