Mult. Test Results for Same Patient Need to Be Put into Single Observation

Reply
New Contributor
Posts: 2

Mult. Test Results for Same Patient Need to Be Put into Single Observation

Hello from Brazil!

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.

Patient_ID Hematocrit1 Hematocrit2 Hematocrit3 Hematocrit4
123 45 37
102 50 51 33

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.

Beijos
Keith
Occasional Contributor
Posts: 11

Re: Mult. Test Results for Same Patient Need to Be Put into Single Observation

Why do the results need to be all in one observation?


proc sort data=XXX;
by Patient_Id date;
run;

proc transpose data=XXXX;
by Patient_ID;
var hematocrit_pct;
run;
New Contributor
Posts: 2

Re: Mult. Test Results for Same Patient Need to Be Put into Single Observat

Thank you!

I need to create a new variable for each patient that presents the percent change from the max. hematocrit level to the min. hematocrit level.
Occasional Contributor
Posts: 11

Re: Mult. Test Results for Same Patient Need to Be Put into Single Observat

You didn't answer my other question....

Next, tell me how you would find the max.
Trusted Advisor
Posts: 2,114

Re: Mult. Test Results for Same Patient Need to Be Put into Single Observation

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.

Doc Muhlbaier
Duke
Ask a Question
Discussion stats
  • 4 replies
  • 480 views
  • 0 likes
  • 3 in conversation