I have a dataset with some variables (var1, var2, var3) which contains numbers but they are recorded as strings. I want to destring them using real().
I am preparing this code, in which I transform the variable with real, generating a new one, I drop the original one, and I save the new one with the name of the original. However, the following error is produced: "2var1 invalid name". I guess the problem is something related with quotation marks but I am not able to see it.
I am preparing this code, in which I transform the variable with real, generating a new one, I drop the original one, and I save the new one with the name of the original. However, the following error is produced: "2var1 invalid name". I guess the problem is something related with quotation marks but I am not able to see it.
Code:
local varlist var1 var2 var3 foreach v of local varlist { gen 2`v' = real(`v') drop `v' rename 2`v' `v' }
Comment