Announcement

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

  • How to make intervals for an income variable

    hello everyone
    I have an income variable that goes from 1 to 5000, and I need to create intervals that go from 500 to 500, however doing it manually is too long. Does anyone have a shorter way?

    this is what i'm doing

    gen ingreso=1 if ingresolaboral<=500
    replace ingreso=2 if ingresolaboral>500 & ingresolaboral<=1000
    replace ingreso=3 if ingresolaboral>1000 & ingresolaboral<=1500
    replace ingreso=4 if ingresolaboral>1500 & ingresolaboral<=2000
    replace ingreso=5 if ingresolaboral>2000 & ingresolaboral<=2500
    replace ingreso=6 if ingresolaboral>2500 & ingresolaboral<=3000
    replace ingreso=7 if ingresolaboral>3000 & ingresolaboral<=3500
    replace ingreso=8 if ingresolaboral>3500 & ingresolaboral<=4000
    replace ingreso=9 if ingresolaboral>4000 & ingresolaboral<=4500

  • #2
    Code:
    gen wanted= ceil(ingresolaboral/500)
    See https://www.stata-journal.com/articl...article=dm0095.

    Comment


    • #3
      Code:
       
       gen wanted= 500 * ceil(ingresolaboral/500)
      gives self-describing bins in so far as each bin is represented by its upper limit.

      Comment


      • #4
        Thank you very much for your help

        Comment

        Working...
        X