Sorry, it's COLUMNS into ROWS. Can't update the title
Hi everyone! I have this data at the patient level and need to convert it at the disease level. One "id" should repeat as much as the "disease_count". For instance, if disease_count = 3, I should have 3 rows of that particular "id":
id dis_name
3 "A"
3 "B"
3 "C"
I tried using reshape but it gives me the same repetition for every id.
Please feel free to ask any questions. I would really appreciate any help. Thanks!
Hi everyone! I have this data at the patient level and need to convert it at the disease level. One "id" should repeat as much as the "disease_count". For instance, if disease_count = 3, I should have 3 rows of that particular "id":
id dis_name
3 "A"
3 "B"
3 "C"
I tried using reshape but it gives me the same repetition for every id.
Code:
* Example generated by -dataex-. For more info, type help dataex clear input float(id disease_count) str1 dis_name_1 float dis_name_1_type str1 dis_name_2 float dis_name_2_type str1 dis_name_3 float dis_name_3_type str1 dis_name_4 float dis_name_4_type str1 dis_name_5 float dis_name_5_type str1 dis_name_6 1 4 "A" 1 "B" 1 "C" 1 "D" 1 "." . "." 2 1 "A" 2 "." . "." . "." . "." . "." 3 3 "A" 1 "B" 1 "C" 1 "." . "." . "." 4 2 "A" 2 "B" 1 "." . "." . "." . "." 5 1 "A" 3 "." . "." . "." . "." . "." 6 1 "A" 4 "." . "." . "." . "." . "." 7 5 "A" 1 "B" 1 "C" 1 "D" 1 "D" 1 "." 8 3 "A" 2 "B" 1 "C" 1 "." . "." . "." 9 4 "A" 1 "B" 1 "C" 1 "D" 1 "." . "." 10 5 "A" 1 "B" 1 "C" 1 "D" 1 "D" 1 "." 11 1 "A" 1 "." . "." . "." . "." . "." 12 1 "A" 5 "." . "." . "." . "." . "." 13 1 "A" 1 "." . "." . "." . "." . "." 14 1 "A" 1 "." . "." . "." . "." . "." 15 1 "A" 2 "." . "." . "." . "." . "." 16 2 "A" 1 "B" 1 "." . "." . "." . "." 17 2 "A" 1 "B" 1 "C" 1 "D" 1 "D" 1 "E" 18 3 "A" 1 "B" 1 "C" 1 "." . "." . "." 19 4 "A" 1 "B" 1 "C" 1 "D" 1 "." . "." 20 4 "A" 2 "B" 1 "C" 1 "D" 1 "." . "." 21 4 "A" 1 "B" 1 "C" 1 "D" 1 "." . "." 22 2 "A" 3 "B" 1 "." . "." . "." . "." 23 2 "A" 1 "B" 1 "." . "." . "." . "." 24 2 "A" 1 "B" 1 "." . "." . "." . "." 25 2 "A" 1 "B" 1 "." . "." . "." . "." 26 2 "A" 1 "B" 1 "." . "." . "." . "." 27 1 "A" 1 "." . "." . "." . "." . "." 28 3 "A" 2 "B" 1 "C" 1 "." . "." . "." 29 2 "A" 1 "B" 1 "." . "." . "." . "." 30 2 "A" 3 "B" 1 "." . "." . "." . "." 31 5 "A" 1 "B" 1 "C" 1 "D" 1 "D" 1 "." 32 7 "A" 1 "B" 1 "C" 1 "D" 1 "D" 1 "E" 33 3 "A" 1 "B" 1 "C" 1 "." . "." . "." 34 1 "A" 4 "." . "." . "." . "." . "." 35 1 "A" 1 "." . "." . "." . "." . "." 36 1 "A" 1 "." . "." . "." . "." . "." 37 1 "A" 2 "." . "." . "." . "." . "." 38 3 "A" 1 "B" 1 "C" 1 "." . "." . "." 39 2 "A" 1 "B" 1 "." . "." . "." . "." 40 1 "A" 2 "." . "." . "." . "." . "." 41 2 "A" 1 "B" 1 "." . "." . "." . "." 42 1 "A" 1 "." . "." . "." . "." . "." 43 3 "A" 3 "B" 1 "C" 1 "." . "." . "." 44 1 "A" 1 "." . "." . "." . "." . "." 45 1 "A" 2 "." . "." . "." . "." . "." 46 1 "A" 1 "." . "." . "." . "." . "." 47 1 "A" 1 "." . "." . "." . "." . "." 48 1 "A" 2 "." . "." . "." . "." . "." 49 1 "A" 1 "." . "." . "." . "." . "." 50 1 "A" 2 "." . "." . "." . "." . "." end
Comment