Dear Community,
I am struggling with renaming my variables using the renvars command in STATA.
Upon importing the excel data, I am using renvars to map the first row names to my data set. However, since the first row contains a lot of spaces, the entire names are not being imported, with spaces being replaced as "_" (underscores). I am trying to find a command such that STATA maps the first row observations as variable names, but excludes all numbers and spaces to only select the alphabets.
I do not want to manually change the names in the excel file and would highly appreciate a solution using STATA alone.
My imported dataset looks like this:
The code I run is:
And the result I get is: 
I would like to know of a method to map the first row as variable names without the spaces.
Regards,
Pranav
I am struggling with renaming my variables using the renvars command in STATA.
Upon importing the excel data, I am using renvars to map the first row names to my data set. However, since the first row contains a lot of spaces, the entire names are not being imported, with spaces being replaced as "_" (underscores). I am trying to find a command such that STATA maps the first row observations as variable names, but excludes all numbers and spaces to only select the alphabets.
I do not want to manually change the names in the excel file and would highly appreciate a solution using STATA alone.
My imported dataset looks like this:
The code I run is:
Code:
import excel "$input/filename.xlsx", sheet("ASSETS") allstring clear drop in 1/6 renvars, map(strtoname(@[1]))
I would like to know of a method to map the first row as variable names without the spaces.
Regards,
Pranav
Comment