Announcement

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

  • Sequence Function with By Option

    Hi Everybody,

    I have a data set as follows with reference and date values. I wanna group every 20 reference numbers and create a variable with respect to their group as I made below for a group of 3 reference numbers to create a group variable.
    As far as I understand, I have to use seq with by option. I tried it but the results didn't appear as I wanted.

    ref I date I group
    1 2011 1
    1 2012 1
    1 2013 1
    1 2014 1
    1 2015 1
    1 2016 1
    2 2012 1
    2 2013 1
    2 2014 1
    7 2012 1
    7 2013 1
    7 2014 1
    8 2012 2
    12 2014 2
    12 2015 2
    12 2016 2
    12 2017 2
    14 2014 2
    14 2015 2
    14 2016 2
    14 2017 2

    Thanks in advance,
    Mahmut

  • #2
    The command seq is community-contributed but was superseded by the egen function seq() — itself long since adopted as official. It is not clear why you want a sequence variable that ignores your identifier and date variables but the block() option allows blocks of 20 (your text), 12 (your example), and so forth.

    Comment


    • #3
      Thank you for your answer, Nick. It's my fault I couldn't explain properly. Actually, in my example, I am not grouping 12 observations, I am grouping 3 different ref (1,2,7)-(8,12,14) regardless of the number of observations for each ref. In my real data, I will group 20 different refs together for each group regardless of the number of observations.

      Comment

      Working...
      X