Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.


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

Re: st: data precision and problems therein


From   Pham Ngoc Minh <[email protected]>
To   "[email protected]" <[email protected]>
Subject   Re: st: data precision and problems therein
Date   Sat, 10 Nov 2012 10:20:30 +0900

Thank you Paul for elaborate explanations, and those commands work well.

Minh

On Fri, Nov 9, 2012 at 11:12 PM, Seed, Paul <[email protected]> wrote:
> Ngoc Minh PHAM points to a problem with non-integer cut-points.
> He can solve it with the -float()- function:
>
> Rather than
>         gen gly_haem_gt_6_1 = gly_haem > 6.1
>
> He can use
>         gen gly_haem_gt_6_1 = gly_haem > float(6.1)
>
> Or (allowing for missing values )
>         gen gly_haem_gt_6_1 = gly_haem > float(6.1) if gly_haem <.
>
> Or (perhaps easier to remember):
>         gen gly_haem_gt_6_1 = float(gly_haem) > float(6.1) if gly_haem <.
>
> This is because his variable is stored as a float (7 decimal places more-or-less),
> but 6.1 is evaluated exactly (or at least to double accuracy).
> Converting a float to exact is impossible (inventing extra decimal places);
> but going the other way is easy (just rounding). And float(float(x)) is the same as
> float(x), so extra float functions are not a problem.
>
> If Ngoc prefers to cut the other way...
>         gen gly_haem_ge_6_1 = float(gly_haem) >= float(6.1) if gly_haem <.
>
>
> Paul T Seed, Senior Lecturer in Medical Statistics,
> Division of Women's Health, King's College London
> Women's Health Academic Centre, King's Health Partners
> (+44) (0) 20 7188 3642.
>
>> Date: Fri, 9 Nov 2012 15:28:08 +0900
>> From: Pham Ngoc Minh <[email protected]>
>> Subject: st: data precision and problems therein
>>
>> Dear statalist,
>>
>> I have a problem with data precision as follows:
>>
>> for example: glycated hemoglobin is 6.1 (%) visible in data editor,
>> but it turns out 6.0999999 when clicked on, so are other numbers (5.6
>> becomes 5.5999999), etc. This affects results of creating dummy
>> variables with pre-defined cut-points of values. How about the
>> solution?
>>
>> Thank you for your advice
>>
>> Ngoc Minh PHAM
>> National Center for Global Health and Medicine, Japan.
>> *
>> *   For searches and help try:
>> *   http://www.stata.com/help.cgi?search
>> *   http://www.stata.com/support/faqs/resources/statalist-faq/
>> *   http://www.ats.ucla.edu/stat/stata/
>>
>
>
>
> *
> *   For searches and help try:
> *   http://www.stata.com/help.cgi?search
> *   http://www.stata.com/support/faqs/resources/statalist-faq/
> *   http://www.ats.ucla.edu/stat/stata/
*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/faqs/resources/statalist-faq/
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index