I used insheet
to read in CSV format data. The names of the variables should be the first line of the dataset. I have a lot of variables and many years of data to read in so I would like to do this using a foreach var
loop as follows:
input str8 x str8 y str8 z
first second third
3 6 2
4 1 2
8 7 6
end
foreach var of varlist * {
rename variable "`var'" "`=`var'[1]'"
}
Unfortunately, I receive a syntax error
response.
I'm assuming the problem must be in the way I specified the new name. I was extrapolating from this Q&A: http://www.stata.com/statalist/archive/2011-09/msg01109.html
insheet
has a[no]names
option. Thehelp
states: "[no]names informs Stata whether variable names are included on the first line of the file." – Roberto Ferrer