[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]
st: Re: transform string to numeric vars
The problem is one of the stored precision of numeric variable types -- a
common topic on the list. You are generating a float var and trying to have
it store 9 digits accurately -- you need to generate a double or long (not
the default float). I haven't checked, but I would guess that destring
checks to see what numeric type is needed to maintain all digits.
----- Original Message -----
From: "Harald Seider" <firstname.lastname@example.org>
Sent: Tuesday, June 03, 2003 1:51 PM
Subject: st: transform string to numeric vars
> Dear List,
> I came across a weird problem with STATAs destring command (I am using
> Stata8 on a XP environment).
> My intention was to transfer a string variable "hospid" into a numeric
> variable (regardless the usefulness of such an action).
> So far I understand there are two ways to proceed: real(var) and destring
> var. I would have expected that both commands will give identical results.
> Unfortunately they don't.
> So I compared both commands:
> 'generate hospidold = real(hospid)' and
> 'destring hospid, generate(hospidnew)'
> When comparing hospidold and hospidnew I get slightly different results.
> variables: hospid(string) hospidold(float)
> content: 106010735 106010736 106010735
> Therefore 'generate hospidold = real(hospid)' gives wrong results.
> Has anybody faced this problem before? Is it a well non issue (I haven't
> found anything on the list so far).
> Harald Seider
> Dipl. oec. Harald Seider
> Department of Economics II
> Universitätsstraße 16
> D-86159 Augsburg
> Tel: +49-821-598 4208
> Fax: +49-821-598 4232
> E-Mail: email@example.com
* For searches and help try: