I have a data set where there are 4 diseases, but the presence of each is entered as a separate observation for every patient ID. I would like to consolidate each patient ID into a single observation with all diseases present. For example:
Starting data set:
ID | A | B | C | D |
12345 | 1 | 0 | 0 | 0 |
12345 | 0 | 1 | 0 | 0 |
98765 | 0 | 0 | 0 | 1 |
98765 | 0 | 1 | 0 | 0 |
98765 | 0 | 0 | 1 | 0 |
Desired result:
ID | A | B | C | D |
12345 | 1 | 1 | 0 | 0 |
98765 | 0 | 1 | 1 | 1 |
Is there a way to achieve this result? Thanks in advance for your help!
Jason
0 Response to How to collapse observations and overwrite variables
Post a Comment