I am working with a dengue database. Each dengue patient's hematocrit levels are measured multiple times to differentiate between dengue fever and dengue hemorrhagic fever. Consequentially, I have a database that looks like this.
Result_ID Patient_ID Hematocrit% ...( various other tests)... Date
67 123 45 07/06/2009
68 123 37 07/07/2009
69 102 50 08/07/2009
70 102 51 08/08/2009
71 102 33 08/09/2009
I need to get all hematocrit tests for a given patient_id into a single observation, so that it looks like this.
The test results do not have to be ordered chonologically (i.e. Hematocrit 1=earliest,Hematocrit 7=latest) but it would be nice. The number of hematorcrit tests for patients ranges from 0 to 7. I do not need any other tests in the new dataset.
I have been racking my brain over this and can't figure it out. Any help/tips would be super appreciated.
This really comes down to a question of which tools you are comfortable with. As the goal is to reduce the data to one number per person (MaxDeltaHctPct), it can be done with the data strung out like Keith wants and computed using the MAX and MIN functions in the DATA step.
It could also be done directly on the original data using the MAX and MIN aggregate functions in SQL (which are somewhat different from the DATA step functions), but that requires a bit more knowledge of SQL than some people might have at their fingertips.