BookmarkSubscribeRSS Feed
KeithAtchison
Calcite | Level 5
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
4 REPLIES 4
MZunnurain
Calcite | Level 5
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;
KeithAtchison
Calcite | Level 5
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.
MZunnurain
Calcite | Level 5
You didn't answer my other question....

Next, tell me how you would find the max.
Doc_Duke
Rhodochrosite | Level 12
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

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 16. Read more here about why you should contribute and what is in it for you!

Submit your idea!

Health and Life Sciences Learning

 

Need courses to help you with SAS Life Sciences Analytics Framework, SAS Health Cohort Builder, or other topics? Check out the Health and Life Sciences learning path for all of the offerings.

LEARN MORE

Discussion stats
  • 4 replies
  • 1301 views
  • 0 likes
  • 3 in conversation