Hello all;
What I have is a set of timestamps and a Patient ID number.
Such as
PAT_ID COL1 COL2 COL3 COL4
123 01JAN17:12:00:00 01JAN17:13:00:00 01JAN17:13:30:00 01JAN17:15:00:00
What I need to do is compute the time differences between col1 & col2, col1&co3 ,col1&co4
then col2&col3, col2&col4
and then finally col3&col4 and then get the first timestamp with the time difference under 120 minutes.
so in the example above it would output col1.
The time stamps above are when a patient when into hypotension-however there has to be at least two episodes within 120 minutes.
Not even sure how to begin the array on this one-
Any assistance on where to begin much appreciated.
Lawrence
data have;
input PAT_ID (COL1 COL2 COL3 COL4) (:datetime20.);
format COL1 COL2 COL3 COL4 datetime20.;
cards;
123 01JAN17:12:00:00 01JAN17:13:00:00 01JAN17:13:30:00 01JAN17:15:00:00
;
data want;
set have;
array col(*) col:;
do i=1 to dim(col)-1;
do j=i+1 to dim(col);
minutes=intck('minute',col(i),col(j));
/*@Lawrence, I am lazy- so Can you write your IF condition here however you want to filter, or let us know if you need detailed help*/
output;/* comment output when you have tested*/
end;
end;
run;
data have;
input PAT_ID (COL1 COL2 COL3 COL4) (:datetime20.);
format COL1 COL2 COL3 COL4 datetime20.;
cards;
123 01JAN17:12:00:00 01JAN17:13:00:00 01JAN17:13:30:00 01JAN17:15:00:00
;
data want;
set have;
array col(*) col:;
do i=1 to dim(col)-1;
do j=i+1 to dim(col);
minutes=intck('minute',col(i),col(j));
/*@Lawrence, I am lazy- so Can you write your IF condition here however you want to filter, or let us know if you need detailed help*/
output;/* comment output when you have tested*/
end;
end;
run;
Many thanks Novinosrin! Worked like a charm!
Lawrence
@LB You are welcome. Feel free to have any follow up questions should you have. I will respond if i am not too tired 🙂
Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.
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.