Hi STATALIST,
I am having a bit of an issue with trying to turn Cancer Registry data from long to wide.
I have the following variables:
ID (id)
Sex (sex)
Age at Enrollment (age_E)
Age at Diagnosis (age_Dx)
Time from Enrollment to Diagnosis (time)
Cancer Site (site)
I want to convert the data set to wide using the variable ID, but none of the other variables can be use to unieuqly add a suffix to the reshaped variables -- this is because some individuals in the data set were diagnosed with multiple primary cancers simultaneously (thus they have the same data across the board).
-duplicates tag- doesn't help, as it only tags the duplicates but does not provide a unique value.
Here is how the code looks:
reshape wide sex age_E age_Dx time site , i(id) j()
I need to create a variable for j(). Does someone have an idea how to create a variable so that every time a duplicate ID is encountered it add 1 (+1) to some variable. Ideally the data would like like the table below...
Thanks in advance for your help.
I am having a bit of an issue with trying to turn Cancer Registry data from long to wide.
I have the following variables:
ID (id)
Sex (sex)
Age at Enrollment (age_E)
Age at Diagnosis (age_Dx)
Time from Enrollment to Diagnosis (time)
Cancer Site (site)
I want to convert the data set to wide using the variable ID, but none of the other variables can be use to unieuqly add a suffix to the reshaped variables -- this is because some individuals in the data set were diagnosed with multiple primary cancers simultaneously (thus they have the same data across the board).
-duplicates tag- doesn't help, as it only tags the duplicates but does not provide a unique value.
Here is how the code looks:
reshape wide sex age_E age_Dx time site , i(id) j()
I need to create a variable for j(). Does someone have an idea how to create a variable so that every time a duplicate ID is encountered it add 1 (+1) to some variable. Ideally the data would like like the table below...
ID | Sex | age_E | age_dx | time | site | cancer # |
1234 | 1 | 50 | 65 | 5475 | lung | 1 |
1234 | 1 | 50 | 65 | 5475 | lung | 2 |
Comment