Creating a new thread for this question:
I was wondering if it would be possible to join a table in Stata onto itself if the data format is already in a long format. Instead of making two copies/tables of the raw data and trying to do a one-to-many merge, is there a good program/function to use to merge a table onto itself and allows for mismatched values to be in separate columns. My example data is below:
I would like to create a wide format table with each row denoting an observation. If DX1, DX2, and DX3 values will not match in the new wide format, then will there be new columns to account for mismatches (eg, DX1, DX2, DX3, DX1', DX2', DX3')?
Thank you in advance for the help!
I was wondering if it would be possible to join a table in Stata onto itself if the data format is already in a long format. Instead of making two copies/tables of the raw data and trying to do a one-to-many merge, is there a good program/function to use to merge a table onto itself and allows for mismatched values to be in separate columns. My example data is below:
ID | Admission Date | DX1 | DX2 | DX3 |
1 | 1/1/2011 | 573.0 | 574.0 | 575.0 |
1 | 2/1/2011 | 573.0 | . | 571.0 |
1 | 3/1/2011 | 573.0 | . | . |
2 | 1/1/2011 | 573.0 | 574.0 | |
2 | 3/1/2011 | 573.0 | 574.0 | 575.0 |
3 | 1/1/2011 | 573.0 | . | 575.0 |
3 | 2/1/2011 | 573.0 | 571.0 | . |
3 | 3/1/2011 | 572.0 | 574.0 | . |
3 | 4/1/2011 | 571.0 | 574.0 | 575.0 |
Thank you in advance for the help!
Comment