Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.
From | Maarten Buis <maartenlbuis@gmail.com> |
To | statalist@hsphsun2.harvard.edu |
Subject | Re: st: Float Precision |
Date | Wed, 22 Aug 2012 11:36:30 +0200 |
On Wed, Aug 22, 2012 at 11:16 AM, Jamie Madden wrote: > For example if we look at (using Stata 12) > > sysuse auto, clear > > at the first row and column "gear_ratio", the value appears to be 3.58 > when in reality when you click on it, it is 3.579999. I understand the > reasoning behind this and understand if I want to create a variable > for example that is greater than or equal to 3.58 I should type > > gen newvariable=1 if gear_ratio>=float(3.58) > > Surely there is no need to type float for every variable that you > create in a dataset? Is there a way to set this up for your whole > dataset? Or change the default setting? Generally I would only use such checks for exact equality for integers, as computers can hold integers exactly. Sometimes you can turn a seemingly non-integer variable into an integer variable, for example by storing sums of money in cents rather than euros (fill in your local currency as required). If you really believe that exact equality is relevant to your problem than I suspect that in most cases your variables are really similar "integers in disguise", and you can use the same trick. Hope this helps, Maarten --------------------------------- Maarten L. Buis WZB Reichpietschufer 50 10785 Berlin Germany http://www.maartenbuis.nl --------------------------------- * * For searches and help try: * http://www.stata.com/help.cgi?search * http://www.stata.com/support/statalist/faq * http://www.ats.ucla.edu/stat/stata/