BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
LB
Quartz | Level 8 LB
Quartz | Level 8

 

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 

1 ACCEPTED SOLUTION

Accepted Solutions
novinosrin
Tourmaline | Level 20
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;

View solution in original post

3 REPLIES 3
novinosrin
Tourmaline | Level 20
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;
LB
Quartz | Level 8 LB
Quartz | Level 8

Many thanks

 

novinosrin
Tourmaline | Level 20

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

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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
  • 3 replies
  • 755 views
  • 0 likes
  • 2 in conversation