Announcement

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

  • Multiplying Variables Output Not Ideal

    I am multiplying two variables (Debt and CPI) to make a third (Adjusted Debt). Yeah, I know, nothing that is too hard to do.

    My issue is that Stata turns the new variable into an one with an exponential form.

    What do I need to do in my syntax to get the equation 73,087,418 * 1.282583 to equal 93,740,679.84 instead of 9.37e+07?

    Currently, the typical syntax of

    gen adj_debt=debt*cpi
    is not cutting it for me.

    TIA

  • #2
    Stata is already doing what you want. The main issue is that you would prefer a different display format.

    The principle is that what is displayed is influenced but not always determined by what is stored.

    For your circumstances, a double data type default might be a good idea. Note that my attempt to reproduce your example didn't trigger the same display format.

    Code:
    . clear 
    
    . set obs 1 
    Number of observations (_N) was 0, now 1.
    
    . set type double
    
    . gen debt = 73087418 
    
    . gen cpi = 1.282583
    
    . 
    . gen adj_debt=debt*cpi
    
    . 
    . list 
    
         +--------------------------------+
         |     debt        cpi   adj_debt |
         |--------------------------------|
      1. | 73087418   1.282583   93740680 |
         +--------------------------------+
    
    . 
    . format adj_debt %12.2f 
    
    . 
    . list 
    
         +-----------------------------------+
         |     debt        cpi      adj_debt |
         |-----------------------------------|
      1. | 73087418   1.282583   93740679.84 |
         +-----------------------------------+

    Comment


    • #3
      This is due to the display format. The number is (more or less) what you expect it to be. To change the the display format you type

      Code:
      format adj_debt %12.0g
      ---------------------------------
      Maarten L. Buis
      University of Konstanz
      Department of history and sociology
      box 40
      78457 Konstanz
      Germany
      http://www.maartenbuis.nl
      ---------------------------------

      Comment


      • #4
        Thank you both. I knew it was something simple. I was unable to gain traction from the search command.

        Comment

        Working...
        X