Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • keep command not removing small values

    I am using the keep command to keep any observation larger than 0.1 but it does not appear to be dropping the 0.1 values
    Code:
    * WIP clean for small AUM
    use ED_fund_data_small_trial.dta
    keep if mtna>0.1
    summarize mtna
    count if mtna==0.1
    Code:
    * Example generated by -dataex-. To install: ssc install dataex
    clear
    input long(crsp_fundno caldt) float(mtna mret mnav)
     2708 20180228 969.7  -.03621 12.51
     2708 20180329 960.2 -.007194 12.42
     2708 20180430 963.5  .004831 12.48
     2708 20180531 964.1  .005609 12.55
     2708 20180629 958.1 -.005578 12.48
     2748 20040630    .1        .     .
     2748 20040730   2.2        . 21.98
     2748 20040831   9.5 -.005914 21.85
     2748 20040930    12  .022883 22.35
     2748 20041029  21.2  .026846 22.95
     2771 20030131    .1 -.025282 18.12
     2771 20030228    .1 -.010486 17.93
     2771 20030331    .1  .030117 18.47
     2771 20030430    .1  .046562 19.33
     2771 20030530    .1  .040352 20.11
     2962 20051130    .1  .037786 11.81
     2962 20051230    .1  .017739 11.99
     2962 20060131    .1  .057548 12.68
     2962 20060228    .1 -.027603 12.33
     2962 20060331    .3  .024331 12.63
    39939 20090130 543.2 -.111954  9.36
    39939 20090227 469.5 -.130342  8.14
    39939 20090331 527.2  .112112  8.96
    39939 20090430 666.9  .254464 11.24
    39939 20090529 702.9  .048043 11.78
    end
    Thank you for your help, Dan

  • #2
    This is a precision problem Remember lesson 1 about computers: they use binary at hardware level. Masses of effort go into hiding this from the user, but sometimes it bites. (Well, it was my lesson 1 age about 12, about 1964.)

    "Precision" is a search term for Stata. I'd start with the blog posts of William Gould.

    Code:
    . clear
    
    . set obs 1
    number of observations (_N) was 0, now 1
    
    . gen whatever = 0.1
    
    . count if whatever == 0.1
      0
    
    . count if whatever == float(0.1)
      1

    Comment


    • #3
      Thank you Nick, I guess it's never too late for that lesson! for anyone chancing upon this discussion, pls see William Gould's explanation and section 13.12 "Precision and problems therein" in the Stata User's Guide release 15. Thank you, Dan
      Last edited by Dan Daugaard; 23 Aug 2018, 20:02.

      Comment

      Working...
      X