Could I possibly have some help with:
a) Identifying the creatinine value closest in time to time 0 for each id number, and
b) Where there are two creatinine values at the same timepoint for a single id, finding the mean of these.
This is a dataset where I have numerous "creatinine" values for each individual (or "id"). Each creatinine value has a time (in days). I need to identify the creatinine value that is closest in time to time 0 for each id, and where there is more than one creatinine value at time 0 (or another timepoint) for each id, find the mean of these values.
For example,
For ID 1 the creatinine I want is 100 (at time 0)
For ID 2 the creatinine I want is 86
For ID 3 the creatinine I want is 482
I won't bother to share my repeated attempts at solving this problem, as none have come close so far!
Apologies for not using dataex. My University is currently having problems with their STATA licence.
Thank you so much for any suggestions.
Jemima Scott
a) Identifying the creatinine value closest in time to time 0 for each id number, and
b) Where there are two creatinine values at the same timepoint for a single id, finding the mean of these.
This is a dataset where I have numerous "creatinine" values for each individual (or "id"). Each creatinine value has a time (in days). I need to identify the creatinine value that is closest in time to time 0 for each id, and where there is more than one creatinine value at time 0 (or another timepoint) for each id, find the mean of these values.
For example,
For ID 1 the creatinine I want is 100 (at time 0)
For ID 2 the creatinine I want is 86
For ID 3 the creatinine I want is 482
I won't bother to share my repeated attempts at solving this problem, as none have come close so far!
id | rownum | tt_troponin | creatinine |
1 | 1 | 0 | 100 |
1 | 2 | 3 | 150 |
2 | 1 | -2 | 82 |
2 | 2 | 0 | 86 |
2 | 3 | 5 | 92 |
3 | 1 | 0 | 452 |
3 | 2 | 0 | 512 |
Apologies for not using dataex. My University is currently having problems with their STATA licence.
Thank you so much for any suggestions.
Jemima Scott
Comment