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: problems with browsing, dropping certain observations
From 
 
Ronan Conroy <[email protected]> 
To 
 
"[email protected]" <[email protected]> 
Subject 
 
Re: st: problems with browsing, dropping certain observations 
Date 
 
Mon, 31 May 2010 13:08:01 +0100 
On 31 Beal 2010, at 12:58, Michael Findley wrote:
I'm puzzled about what seems to be a simple formatting issue. I  
import a .csv file with variables that range from .001 to .009. I  
can carry out certain commands, such as generate a new variable that  
has similar values, but I cannot perform other simple tasks such as  
"browse if variable == .001" or "keep if variable == .001". The  
variable is formatted as a float (%9.0g), which is a general format  
that should allow this as I understand it. I was worried that  
importing the data caused the problem, but when I just open stata  
and enter similar values, I get the same thing. I also tried  
reformatting the variable to several different fixed formats, but  
still no luck. What am I missing? Any thoughts greatly appreciated.
Stata's internal representation of decimal numbers isn't exactly exact  
(the problem is mapping decimal numbers onto binary representations).
. set obs 9
obs was 0, now 9
. gen foo=0.001*_n
. list
     +------+
     |  foo |
     |------|
  1. | .001 |
  2. | .002 |
  3. | .003 |
  4. | .004 |
  5. | .005 |
     |------|
  6. | .006 |
  7. | .007 |
  8. | .008 |
  9. | .009 |
     +------+
. tab foo if foo==0.003
no observations
. tab foo if round(foo,0.001)==0.001
        foo |      Freq.     Percent        Cum.
------------+-----------------------------------
       .001 |          1      100.00      100.00
------------+-----------------------------------
      Total |          1      100.00
You can use the -round- function to make sure that Stata rounds the  
stored value to the exact number you want to match.
Ronan Conroy
=================================
[email protected]
Royal College of Surgeons in Ireland
Epidemiology Department,
Beaux Lane House, Dublin 2, Ireland
+353 (0)1 402 2431
+353 (0)87 799 97 95
+353 (0)1 402 2764 (Fax - remember them?)
http://rcsi.academia.edu/RonanConroy
P    Before printing, think about the environment
*
*   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/