Announcement

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

  • Help with rescaling

    Hello Everyone,

    I am fairly new to Stata so this question might be basic. In a dataset, I have age in continuous form (for example, 25, 26, 28, 32, 36 and so on). I would like to re-scale age into 5 year increments and then run a linear regression using the re-scaled variable. How do I implement the re-scaling in Stata. Your help would be much appreciated.

    Al Bothwell




  • #2
    Why throw away information? Let's suppose I am 16. You could round my age to 15 or to 20. Either way, I object, and more importantly, why throw away information?

    Comment


    • #3
      I agree with Nick if the intend was to round the age. An alternative I use often is to just change the unit by dividing the old age variable by 5. So in a regression analysis we see the effect of getting 5 years older.
      ---------------------------------
      Maarten L. Buis
      University of Konstanz
      Department of history and sociology
      box 40
      78457 Konstanz
      Germany
      http://www.maartenbuis.nl
      ---------------------------------

      Comment


      • #4
        While agreeing with Nick and Maarten, to directly answer your question, you could use recode to do the recoding. There are more elegant ways to do it, but recode works.

        Comment


        • #5
          I dislike recode because, recursively, I dislike recode and don't usually use it, or exceptionally have to relearn some of its syntax on the very odd occasions I try to debug someone else's recode code. That is purely personal and not worth a microhill of microbeans.

          But I think it's worth pointing out ways of rounding in 5 unit intervals:

          Code:
           
          generate newto = round(old, 5) 
          generate newup = 5 * ceil(old/5) 
          generate newdn = 5 * floor(old/5)
          I've asked in the past for

          Code:
           
          * syntax not supported yet! 
          generate newup = ceil(old, 5) 
          generate newdn = floor(old, 5)
          One enormous advantage of any of these is that the new values are self-describing, given the function used.

          Comment


          • #6
            I ended up using what Maarten suggested:

            HTML Code:
            generate age5=age/5

            Thus, a unit change corresponds to five years. This is exactly what I wanted.

            Thank you everyone!
            Al Bothwell


            Comment

            Working...
            X