Announcement

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

  • Creating new variable across rows

    Hello,

    I'm trying to create the following 'new_var' by concatenating the radio_show entries by id. Any help with how to go about this would be greatly appreciated.

    id radio_show new_var
    acc 1 123
    acc 2 123
    acc 3 123
    hg 2 24
    hg 2 24
    tgc 5 544
    tgc 5 544
    bvv 4 4
    nnc 2 2
    Thanks
    Johanna

  • #2

    Code:
    gen wanted = "" 
    bysort id (radio_show) : replace wanted = wanted[_n-1] + string(radio_show) 
    by id: replace wanted = wanted[_N]

    Comment


    • #3
      Thank you so much Nick!

      Comment

      Working...
      X