I am using Stata, and I would like to generate a log variable based on my current available variables. However, I have too many variables and using generate command will take too much time. Is there a way to do this more efficiently?
Say, I am using:
gen log_gdp = log(gdp)
then I have to do this to every variable.
Is there a way to instead do, for every variable,
gen log_varname = log(varname)
You can use
dsin combination with a loop. Seehelp dsfor options on how to exclude or include different variables. I includedhas(type numeric)to exclude all string variables as you cannot take the log of a string.See this example using the built-in data set
auto.