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.
I would much appreciate your help in this matter.
Thank you!
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
Thank you!
Comment