Statalist


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

Re: st: real vs destring


From   Maarten buis <maartenbuis@yahoo.co.uk>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: real vs destring
Date   Fri, 4 Apr 2008 15:25:23 +0100 (BST)

--- Nicholas Harrigan <nicholas.harrigan@nuffield.ox.ac.uk> wrote:
> I am trying to recode a variable containing large numbers which are 
> currently held as strings.
> 
> I am wondering why real and destring give different results
> 
> "5560001090"
> when I run real I get:    5560001024   
> when I run destring I get: 5560001090
> 
> "5560001108"
> when I run real I get:     5560001024   
> when I run destring I get:  5560001108
> 
> Does this mean I should use always use destring in my coding instead
> of 
> real?
> 
> The commands I use are these:
> 
> gen new_var = real(old_var)
> gen new_var2 = old_var
> destring new_var2, replace
 
No, the issue here is precision, you can get the same results as
destring if you typed:

gen double new_var = real(old_var)

If you search the statalist archive on precision you will find many
many good posts on that issue.

Hope this helps,
Maarten

-----------------------------------------
Maarten L. Buis
Department of Social Research Methodology
Vrije Universiteit Amsterdam
Boelelaan 1081
1081 HV Amsterdam
The Netherlands

visiting address:
Buitenveldertselaan 3 (Metropolitan), room Z434

+31 20 5986715

http://home.fsw.vu.nl/m.buis/
-----------------------------------------


      ___________________________________________________________ 
Yahoo! For Good helps you make a difference  

http://uk.promotions.yahoo.com/forgood/
*
*   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/



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