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-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

New Learning Events in April

 

Join us for two new fee-based courses: Administrative Healthcare Data and SAS via Live Web Monday-Thursday, April 24-27 from 1:00 to 4:30 PM ET each day. And Administrative Healthcare Data and SAS: Hands-On Programming Workshop via Live Web on Friday, April 28 from 9:00 AM to 5:00 PM ET.

LEARN MORE

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