Announcement

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

  • Missing value generated from exp() function !?

    Hello Stata experts !

    I have an issue with exponentiation of big numbers with Stata so i can make some calculations and then take the logarithm again. Basically using the -exp()- function with values around above 90 returns me missing values ! I wonder why this is and how it can be solved ?

    I post a small sample of my input data and output data.

    This might be a simple problem and I can do it "outside" stata but still I am wondering how it can be solved with Stata.



    Input data

    dataex LCpeakCh1P1dB LAFmaxCh1P1dB LAFminCh1P1dB LAeqCh1P1dB LCpeakCh1P2dB LCFmaxCh1P2dB if RECORD>17000

    copy starting from the next line -----------------------
    [CODE]
    * Example generated by -dataex-. To install: ssc install dataex
    clear
    input double(LCpeakCh1P1dB LAFmaxCh1P1dB LAFminCh1P1dB LAeqCh1P1dB LCpeakCh1P2dB LCFmaxCh1P2dB)
    92.2 79.5 56.7 68.1 92.2 81.5
    92.6 79.7 60.2 69.4 92.6 82.6
    91.6 79.9 56.8 67 91.6 81.7
    95.9 80 54.5 69.9 95.9 88
    end

    /CODE -foreach var in LCpeakCh1P1dB LAFmaxCh1P1dB LAFminCh1P1dB LAeqCh1P1dB LCpeakCh1P2dB LCFmaxCh1P2dB ///
    LCFminCh1P2dB LCeqCh1P2dB LZpeakCh1P3dB LZFmaxCh1P3dB LZFminCh1P3dB LZeqCh1P3dB LZeqCh13150HzdB ///
    LZeqCh16300HzdB LZeqCh112500HzdB LZeqCh125000HzdB LZeqCh150000HzdB LZeqCh1100000HzdB ///
    LZeqCh1200kHzdB LZeqCh1400kHzdB LZeqCh1800kHzdB LZeqCh11600kHzdB LZeqCh110dB LZeqCh111dB LZeqCh112dB {
    generate Exp_`var'=exp(`var')
    }-

    Output data

    dataex Exp_LCpeakCh1P1dB Exp_LAFmaxCh1P1dB Exp_LAFminCh1P1dB Exp_LAeqCh1P1dB Exp_LCpeakCh1P2dB Exp_LCFmaxCh1P2dB if RECORD>17000

    copy starting from the next line -----------------------
    Code:
    * Example generated by -dataex-. To install: ssc install dataex
    clear
    input float(Exp_LCpeakCh1P1dB Exp_LAFmaxCh1P1dB Exp_LAFminCh1P1dB Exp_LAeqCh1P1dB Exp_LCpeakCh1P2dB Exp_LCFmaxCh1P2dB)
    . 3.360557e+34 4.212085e+24 3.7623067e+29 . 2.4831346e+35
    . 4.104594e+34 1.394851e+26  1.380502e+30 .  7.459749e+35
    . 5.013363e+34 4.655074e+24 1.2523632e+29 . 3.0329075e+35
    . 5.540622e+34 4.667123e+23  2.276063e+30 . 1.6516363e+38
    end

  • #2
    Do study

    Code:
    help data_types
    to see that you need doubles here. There is usually an algebraic way to avoid all this, but the details of your intended calculations are not clear.

    Comment


    • #3
      Thank you Professor Cox. Indeed I am aware that there is a way to by-pass this but my algebra is rusty.

      Thank you again.

      Comment

      Working...
      X