## arrays -computing time values against each other

Solved
Regular Contributor
Posts: 161

# arrays -computing time values against each other

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

Accepted Solutions
Solution
‎05-03-2018 06:05 PM
Super User
Posts: 2,049

## Re: arrays -computing time values against each other

[ Edited ]
``````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;``````

All Replies
Solution
‎05-03-2018 06:05 PM
Super User
Posts: 2,049

## Re: arrays -computing time values against each other

[ Edited ]
``````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;``````
Regular Contributor
Posts: 161

## Re: arrays -computing time values against each other

Posted in reply to novinosrin

Many thanks

Super User
Posts: 2,049

## Re: arrays -computing time values against each other

@LB You are welcome. Feel free to have any follow up questions should you have. I will respond if i am not too tired

☑ This topic is solved.

Need further help from the community? Please ask a new question.

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