On Jan 9, 2007, at 1:21 PM, David Kantor wrote:
Insheet, at least as it has been up to Stata 8, behaves
ungracefully if the second line contains var lables (and var names
are in the first line), which is how some raw datasets are
composed. In this case, you get everything as string -- usually
very long ones. And the var names in the raw data are ignored; you
get default names v1, v2, etc.. And what were supposed to be the
var names and labels end up as data in the first and second
observations.
In Stata 9, the -names- option causes -insheet- to handle the
variable names properly:
[...]
Of course, the variable labels still need to be dealt with.
If you encounter this situation, you may want to use - convert_top_lines-.
I just took a look at the code, and -convert_top_lines- could also
benefit from a function to generate Stata names from strings (i.e.,
if a variable name in the first row of the data file is not a valid
Stata name, -convert_top_lines- currently throws an error). You can
of course trap this error as Nick pointed out, but you're then still
left with the question of what to name the corresponding variable.
It would be nice to do this in a way that was guaranteed to be
consistent with the way -insheet- does it (in case you were making
use of both on the same project).
Thank you for that information and the suggestion. I would put on my
wishlist for -insheet- to have an option to handle the
var-labels-in-second-line situation.