Announcement

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

  • Creating identifier for groups of rows

    Hello,
    I'm generating data and want to create an identifier for groups of rows. Suppose I first generate an id for every observation:
    Code:
    gen id = _n
    After that I want to create a new variable with value 1 for obervation 1 to 10; value 2 for observation 11-20 etc.
    Is there a convenient procedure to do this?

    Thank you,
    Mike


  • #2
    Here are two ways to do that:

    Code:
    gen id1 = ceil(_n/10) 
    
    egen id2 = seq(), block(10)

    Comment


    • #3
      Many thanks!

      Comment

      Working...
      X