Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
st: -insheet- doesn't respect quotes
From
"Joseph Coveney" <[email protected]>
To
<[email protected]>
Subject
st: -insheet- doesn't respect quotes
Date
Sat, 21 Aug 2010 00:18:47 +0900
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
. set obs 2
obs was 0, now 2
. generate str patient_nr = "002"
. tempfile tmpfil0
. outsheet using `tmpfil0', names quote
. type `tmpfil0'
patient_nr
"002"
"002"
. insheet using `tmpfil0', names clear
(1 var, 2 obs)
. describe
Contains data
obs: 2
vars: 1
size: 10 (99.9% of memory free)
--------------------------------------------------------------------------------
---------
storage display value
variable name type format label variable label
--------------------------------------------------------------------------------
---------
patient_nr byte %8.0g
--------------------------------------------------------------------------------
---------
Sorted by:
Note: dataset has changed since last saved
. list
+----------+
| patien~r |
|----------|
1. | 2 |
2. | 2 |
+----------+
*
* 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/