Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down at the end of May, and its replacement, statalist.org is already up and running.


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: st: -insheet- doesn't respect quotes


From   "Airey, David C" <david.airey@Vanderbilt.Edu>
To   "statalist@hsphsun2.harvard.edu" <statalist@hsphsun2.harvard.edu>
Subject   Re: st: -insheet- doesn't respect quotes
Date   Fri, 20 Aug 2010 10:59:57 -0500

.

I also can't get -insheet- to use quotes around numbers to indicate the content as string, but I can get infile to do that. However, -infile- doesn't have a "names" option.

You could add text to the patient numbers, like "002_p" and -split- it later.

What does insheet do with the quotes in a file? Does it just strip them and then let another demon make the choice of whether the contents are string or not, having no idea quotes were present? <Sigh...reading glasses have been ordered>.

clear
set obs 2
generate str patient_nr = "002"
tempfile tmpfil0
outsheet using `tmpfil0', quote nonames
type `tmpfil0'
infile str3 patient_nr using `tmpfil0', clear
describe


> Is there any way to get -insheet- to respect quoted numbers that have leading 
> zeroes?  See the example below for illustration of the problem.  
> 
> -insheet- insists upon importing these strings as numeric.  They really should
> be kept as strings, because they are identifiers and are not intended to be 
> used in calculations.  I can re-generate the strings from the integers using 
> -tostring . . ., format(%0X.0f)-, but every extra workaround is one more 
> opportunity for errors to arise during data management.
> 
> Joseph Coveney

*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index