Announcement

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

  • Generating sequence or pattern of observation of variables

    I am trying to create a new variable that is the sequence of observations of 3 variables

    Code:
    clear
    input id var1 var2 var3
    1 1 2 3
    2 2 2 2
    3 3 3 3
    4 3 3 3
    5 3 1 1
    6 2 2 2
    end
    In this data, I want to generate a new variable seq which would take the value from the 3 variables as

    Code:
    input seq
    123
    222
    333
    333
    311
    222
    end
    At the end, I would like to know the number of observations in each pattern
    Code:
    tab seq
    Can anyone please help?

  • #2
    Code:
    egen seq = concat(var*)

    Comment


    • #3
      Oyvind Snilsberg Thank you so much

      Comment

      Working...
      X