Hi Guys: I am banging my head trying to figure out how to look at a longitudinal profile and to determine two Metrics.
One: Time a patient spent below a given threshold
Two Time weighted Average: defined as the area below the threshold divided by patients overall exposure.
The data is in long form:
ID RESULT DATETIME
1 x1 D1
1 x2 D2
1 x3 D3
etc for patients 1-n.
The first datestamp is baseline and the last is their last measurement.
I know cumulative exposure time is lastdate-Firstdate.
What I am trying to figure out is (cumulative time < threshold) for every patient
and (Area under the threshold curve/cumulative exposure) for every patient.
I naively assumed I could set my data keeping only values below threshold and then computing the metrics as follows.
data map&threshold._actual_final;
set MAP_Actual1;
where result LE &threshold;
by MRN;
area + dif(time_from_admission)*mean(result,lag(result));
timeLT&threshold+dif(time_from_admission);
TWAP=area/cumulative_exposure;
if first.MRN then do;
area=0;
timeLT&threshold=0;
end;
if last.MRN then output;
run;
I think this is over inflated because the data is not evenly spaced and patients can have values above and below any particular threshold over the time span. Also please excuse if I missed the boat on what I supplied but I never want to ask questions until I at least have tried and know the issues involved.
Thanks guys. Totally struggling on this one.
I attached some simulated data with a threshold of 0.5 to give you an idea of what I am trying to do. For example patient 1 in red, over time can oscillate over and below the threshold over time so I dont think I can just restrict my data and compute area etc as I outlined above.
yours in Frustration
A picture is not data. I am not even sure that your picture represents input data or the result of your data step.
Actual example values, fake are fine as long as the behavior of the data is the same. And what a hand-worked example of the results of that data should be would be very helpful.
Is the "area" calculation supposed to reset when the threshold is crossed? I think if work with your data by hand when the result crosses thresholds that your are actually creating a time-interval that includes the time above the threshold and connecting the results incorrectly.
Please look at the following code and results. if I follow your code you are including the area bounded by the two vertical reference lines and the Y2 line. I suspect that you would only want the left and right tails. Let us know if my interpretation is correct.
data example; do i= 0 to constant('pi') by .1; y= sin(i); if y > .6 then y2=.; else y2=y; output; end; run; proc sgplot data=example; series x=i y=y; series x=i y=y2; refline 0.6 /axis=x; refline 2.5 /axis=x; run;
Thanks for the response. The issue is the TWAP was not defined in the paper. Only roughly as Area under a threshold curve divided by the overall time on study. I am trying to make sense of what that actually means. In this case the threshold is a fixed constant and Im not sure what Area under this curve means. Sorry if I'm not conveying the issues appropriately.
The data I have is irregular spaced mean arterial pressures for every patient over time. I am trying to figure out what this metric is and what it means as I have been asked to create this for a project I am working on.
I am not going to make many guesses since this related to medical issues and the potential for harm from my misunderstanding is way to great.
I can say that your time weighting likely differed from the paper. You are using the difference in datetime values directly, which are seconds. The paper say they were using time measured in minutes. So you would need to change your time intervals with division by 60 or use the Minute function on the difference.
Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!
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.
Ready to level-up your skills? Choose your own adventure.