Hi all.
I have been struggling with the issue for a few days and seriously need your help.
I have a dataset that includes multiple blood test result from the same participants.
It looks like this;
I need to pick up the results that have the highest test result value in each patient (flagged with red colour in the table above)
I tried the commands below but did not work (the commands drop the data that meant to be preserved).
bysort id: egen max_data=max(data)
drop if data < max_data
The commands above actually dropped some of the samples where data==max_data.
Do you have any solutions for this situation?
Thank you for your support.
Ayaka
I have been struggling with the issue for a few days and seriously need your help.
I have a dataset that includes multiple blood test result from the same participants.
It looks like this;
Result ID | Patient ID | Test result |
1 | 11111 | 10 |
2 | 11111 | 20 |
3 | 11111 | 30 |
4 | 11112 | 10 |
5 | 11112 | 20 |
I need to pick up the results that have the highest test result value in each patient (flagged with red colour in the table above)
I tried the commands below but did not work (the commands drop the data that meant to be preserved).
bysort id: egen max_data=max(data)
drop if data < max_data
The commands above actually dropped some of the samples where data==max_data.
Do you have any solutions for this situation?
Thank you for your support.
Ayaka
Comment