I have a large dataset that lists patient diagnosis in a single row with a patient name. Additional diagnosis are listed in new rows, but the names and other variables are not duplicated.
I'm attaching a sample dataset of what I have, and what I want it to look like. In the below example, patient Joe owns all the diagnosis in his row, and the diagnosis listed below that until Phil's row.
Any advice on how to make this work?
What I have:
What I'm trying to get:
I'm attaching a sample dataset of what I have, and what I want it to look like. In the below example, patient Joe owns all the diagnosis in his row, and the diagnosis listed below that until Phil's row.
Any advice on how to make this work?
What I have:
| patient | age | gender | diagnosis |
| Joe | 39 | m | diabetes |
| htn | |||
| oud | |||
| aud | |||
| Phil | 43 | f | fx |
| pna | |||
| cellulitis | |||
| sepsis | |||
| pain | |||
| diabetes | |||
| Jen | 40 | f | htn |
| fx1 | |||
| Valerie | 44 | m | fx2 |
| lac | |||
| contusion | |||
| aud | |||
| stim |
What I'm trying to get:
| patient | age | gender | diagnosis |
| Joe | 39 | m | diabetes htn oud aud |
| Phil | 43 | f | fx pna cellulitis sepsis pain diabetes |
| Jen | 40 | f | htn fx1 |
| Valerie | 44 | m | fx2 lac contusion aud stim |

Comment