Statalist The Stata Listserver


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

Re: st: how does insheet determine datatypes?


From   Phil Schumm <[email protected]>
To   [email protected]
Subject   Re: st: how does insheet determine datatypes?
Date   Sun, 7 Jan 2007 18:16:32 -0600

On Jan 7, 2007, at 12:09 PM, Nick Cox wrote:
This particular problem can be avoided by using -capture- as a prefix.

capture ren `var' `=`var'[1]'

will eat the error if the first value is not a valid new variable name. Alternatively you could use -confirm- directly.

Thanks for pointing that out -- I should have written the example that way. Production code would of course need this even with a function to generate Stata names, to account for the possibility of duplicate names (either because of duplicate names in the data file or because a name in the file clashes with one of the automatic names Stata generates when -nonames- is used (i.e., v1, v2, ...)).

I gather from your response that you are unaware of an exposed function to generate Stata names from an existing string?


-- Phil

*
* For searches and help try:
* http://www.stata.com/support/faqs/res/findit.html
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/




© Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index