Announcement

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

  • Add rows with 0 per individual when no observations

    Dear Statalist users,

    In my dataset I have multiple rows for each person (ID). Each person can be attributed to several of 15 groups, A to O. And for each group, when there are observations, it is given a value, see example below.

    I would like to add rows so every person has one row for each group value A-O, i.e. when there are no observations, I would still have a row with the given value 0. Ultimately, every person has a row from A to O.


    Code:
    * Example generated by -dataex-. For more info, type help dataex
    clear
    input str5 ID str76 group double value
    "1" "A" 100
    "1" "B" 200
    "1" "C" 150
    "1" "D" 10
    "1" "F" 10
    "1" "J" 100
    "2" "G" 10
    "2" "B" 50
    "2" "C" 300
    "2" "D" 50
    "2" "E" 200
    "2" "H" 150
    "2" "J" 300
    
    end
    I would much appreciate your help in this matter.
    Thank you!

  • #2
    Code:
    help fillin
    search fillin, sj

    Comment


    • #3
      Thank you very much Nick,
      Problem solved!

      Comment

      Working...
      X