Hi!
I would like to create a distinct row for each observation in the diagnosis-variables (= one diagnosis) per id and date.
My data looks like this:
(The real dataset contains 21 diagnosis variables and >1000 unique id)
I want it to turn out like this:
I would really appreciate your help.
Thank you
I would like to create a distinct row for each observation in the diagnosis-variables (= one diagnosis) per id and date.
My data looks like this:
id | date | diagnosis1 | diagnosis2 | diagnosis3 |
1 | 2023-01-01 | A | . | . |
1 | 2023-01-02 | B | . | . |
2 | 2023-02-03 | F | G | . |
2 | 2023-03-03 | A | F | C |
2 | 2023-03-04 | A | . | . |
I want it to turn out like this:
id | date | newvar |
1 | 2023-01-01 | A |
1 | 2023-01-02 | B |
2 | 2023-02-03 | F |
2 | 2023-02-03 | G |
2 | 2023-03-03 | A |
2 | 2023-03-03 | F |
2 | 2023-03-03 | C |
2 | 2023-03-04 | A |
I would really appreciate your help.
Thank you
Comment