Thanks for the refresher, Nick. I had forgotten that it's possible to
override the default -string()-behavior.
-JW
-----Original Message-----
From: Nick Cox [mailto:[email protected]]
Sent: Wednesday, May 19, 2004 1:31 PM
To: [email protected]
Subject: st: RE: Long integer as string bugaboo
. gen var1 = substr(string(numvar, "%12.0f"),1,6)
You need to provide a format to override -string()-
Also, the sometimes maligned -tostring- has a default
which avoids the need for working this out for yourself,
plus extra safety features.
Nick
[email protected]
-----Original Message-----
From: [email protected]
[mailto:[email protected]]On Behalf Of Wallace, John
Sent: 19 May 2004 21:03
To: '[email protected]'
Subject: st: Long integer as string bugaboo
Sorry to rehash old problems, but several archive searches haven't been
on-point enough at the moment. The problem is I have a serial number that I
want to parse into two different variables. The serial is stored as double,
but when I try to -string()- it I get the following:
In:
numvar
123456001
123457001
123458001
.gen var1=substr(string(numvar),1,6)
out:
var1
1.23e+
1.23e+
1.23e+
I know I dealt with this once in the past, but I can't remember how I
handled it.
John Wallace | Research Associate | Test Method Development
AFFYMETRIX, INC. | 3380 Central Expressway | Santa Clara, CA 95051 | Tel:
408-731-5574 | Fax: 408-481-0435
*
* 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/