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
"Seed, Paul" <[email protected]>
To
"[email protected]" <[email protected]>
Subject
RE: st: data precision and problems therein
Date
Fri, 9 Nov 2012 14:12:42 +0000
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/