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

From |
Keith Dear <keith.dear@anu.edu.au> |

To |
statalist@hsphsun2.harvard.edu |

Subject |
Re: st: question on datatypes |

Date |
Thu, 20 Oct 2005 16:24:19 +1000 |

Hi Florence,

It seems to work ok if you declare the non-decimal version as a "long" (integer).

KD

. version

version 8.2

. clear

. input double x

x

1. 150.089873

2. end

. format x %10.6f

. gen long y=x*1e6

. describe

Contains data

obs: 1

vars: 2

size: 16 (99.9% of memory free)

-------------------------------------------------------------------------------

storage display value

variable name type format label variable label

-------------------------------------------------------------------------------

x double %10.6f

y long %12.0g

-------------------------------------------------------------------------------

. list, clean

x y

1. 150.089873 150089873

At 03:09 PM 20/10/05, you wrote:

Hello, I have a question, I have variables that are coded in as 2-3 digits and 6 decimal places after that, e.g. 150.089873 and I want to convert this to get rid of the decimal places so it looks like 150089873 but when I just multiply by 1000000 then it keeps storing it as a "float" display i.e. 1.5E8 and more than that, the last decimal places are actually INCORRECT in the new version...it will say 1.50089875 instead...which is INCORRECT. I am using Stata 8 and that is where this problem occurs. I was wondering what the easiest way is to change datatypes that something is input in so that it will not be a problem.

Thanks,

florence

*

* 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/

========================================================== Dr Keith B.G. Dear Senior Fellow in Biostatistics National Centre for Epidemiology and Population Health (NCEPH) The Australian National University Canberra, ACT 0200, Australia Tel: 02 612 54865, Fax: 02 612 50740 http://nceph.anu.edu.au/Staff_Students/staff_pages/dear.php CRICOS provider #00120C * * 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/

**References**:**st: question on datatypes***From:*"NEYMOTIN, FLORENCE" <neymotin@calmail.berkeley.edu>

- Prev by Date:
**st: Update to -kdens- on SSC** - Next by Date:
**st: bootstrapped std errors in two stage estimation** - Previous by thread:
**st: question on datatypes** - Next by thread:
**st: RE: Re: RE: controlling what variables to dropping?** - Index(es):

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