Statalist


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

RE: st: RE: insheet numeric variables as strings


From   "Nick Cox" <n.j.cox@durham.ac.uk>
To   <statalist@hsphsun2.harvard.edu>
Subject   RE: st: RE: insheet numeric variables as strings
Date   Thu, 21 May 2009 10:40:56 +0100

Naturally I agree that numeric codes with embedded points are tricky and
should be read in as strings. 

But please note also that the problem reported, as echoed below, was
that what the user regards as strings were being read in as integers. To
that problem -tostring- remains a reasonable and practical solution. 

It's always unwise to assume universal understanding of details such as
what ICD-9 codes are. 

Nick 
n.j.cox@durham.ac.uk 

Roy Wada
 
-chewfile- would be one line for the user. I'll even write the help 
file and send it to Kit.
 
ICD-9 codes are triple digits plus at least two decimals, depending 
on the flavor. You need to put back one or two leading zeros, plus 
worry about the floating points, and still not get it right because 
the number of decimals could be moving up and down.

Nick Cox 
 
> Roy Wada detailed a strategy to ensure that those variables are read
in
> as you want. 
> 
> An alternative downstream fix is to -tostring- the mis-read integer
> variables with a leading zero format. That's a single line. 
 
Xia Jing
 
> I am reading a comma delimited file (.txt) to STATA with "insheet",
but
> I'd like to make sure some variables are read in as strings, as I do
not
> want to lose leading zeros in these variables (ICD-9 procedure codes).

> 
> Stata currently reads them in as integers.
> 
> I know I can manually change the first line values of these variables
to
> some artificial characters. But with large files and large number of
> variables, this approach becomes quite inconvenient. I'm writing to
ask
> whether there is a better way to do this.

*
*   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   |   What's new   |   Site index