BookmarkSubscribeRSS Feed
deleted_user
Not applicable
Hi All,

I have longitudinal clinical data in the long format, where patients get multiple labs over the course of treatment. For example:

PID TEST_DATE RESULT
1 02JUN2005 399
1 11SEP2005 412
1 04DEC2005 1002
1 02FEB2006 2700
2 18FEB2007 53
2 09MAR2007 102

I need to find patients with two or more consecutive RESULT values greater than a threshold, for example, 1000. These patients would be considered to failed treatment. I created a variable indicating results >=1000 so that the data looks like:

PID TEST_DATE RESULT X1000
1 02JUN2005 399 0
1 11SEP2005 412 0
1 04DEC2005 1002 1
1 02FEB2006 2700 1
2 18FEB2007 53 0
2 09MAR2007 102 0

I sorted by PID and TEST_DATE and created a new data set by PID, but I am stuck on what to do next. Here patient 1 is a failure. I need to (1) create a variable identifying patients that experienced treatment failure; and (2) create another variable with the first date defining failure for each patient that failed. Here, for patient 1 the date of failure would be 04DEC2005.

Any suggestions?

Thanks!
2 REPLIES 2
sbb
Lapis Lazuli | Level 10 sbb
Lapis Lazuli | Level 10
A programming sequence involving multiple DATA steps as an approach (on sorted observations) should work. You will need to consider using MERGE to "flag" PID instances that are candidates. Also, look at using a RETAIN stmt to capture and track your "first date" conditions, as well.

Attack the requirements/tasks one at a time, as you develop your SAS application program, considering that along the way you may have some adjustments that need to be made. Use DATA step diagnostic techniques, such as one or more:

PUTLOG '>diag-nn' / _ALL_;

placed in your program, with "nn" being unique for each instance -- this helps you learn / understand the SAS observation/variable values and condition as the program executes.

Lastly, you will find a wealth of information at the SAS support http://support.sas.com/ website, including SAS-hosted product documentation and also supplemental technical/conference papers on related topics.

Scott Barry
SBBWorks, Inc.
DanielSantos
Barite | Level 11
Hello.

This would be easily done, by retaining the previous observation (and comparing with the current one) of the sorted dataset.

Check the online documention of the RETAIN statement here:
http://support.sas.com/documentation/cdl/en/lrdict/61724/HTML/default/a000214163.htm

See also some more reading about retaining values:
http://support.sas.com/documentation/cdl/en/basess/58133/HTML/default/a001310768.htm

Cheers from Portugal.

Daniel Santos @ www.cgd.pt.

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!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 2 replies
  • 909 views
  • 0 likes
  • 3 in conversation