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
... View more