## Array code

Super Contributor
Posts: 1,041

# Array code

Could some one suggest an array code for the structure below

IN1 OUT1 IN2 OUT2 IN3 OUT3 IN4 OUT4 DTMIN1 DTMOUT1 UNIT1 DTMIN2 DTMOUT2 UNIT2 DTMIN3 DTMOUT3 UNIT3 DTMIN4 DTMOUT4 UNIT4

there is one record per ID

IN(n) and OUT(n) is a pair....the time a patient is ON and OFF the ventilator

DTMIN(n) and DTMOUT(n) is also a pair-the time a person came into a department and goes out of the department(unit)...

we are looking to see which department/unit he was in, at the time when he was on the ventilator

.if the condition satisfies we need to grab that DTMIN(n) , DTMOUT(n) and the UNIT(n)........

1)first check if IN1 or OUT1 of the pair falls with in any of the 5 DTMIN-DTMOUT pairs. If it falls then grab that information

2)next check if IN2 or OUT2 of the pair falls with in any of the 5 DTMIN-DTMOUT pairs. If it falls then grab that information

2)next check if IN3 or OUT3 of pair falls with in any of the 5 DTMIN-DTMOUT pairs. If it falls then grab that information

2)next check if IN4 or OUT4 pair falls with in any of the 5 DTMIN-DTMOUT pairs. If it falls then grab that information

thanks

Posts: 4,736

## Re: Array code

First build the logic for a single in/out and dtmin/dtmout pair. Once you have that working create 2 arrays for these pairs and iterate through all the combinations using 2 nested loops (so check every single in/out pair against all the dtmin/dtmout pairs).

Happy to provide some code for this if you provide a data step creating some sample data for all these variables.

Super User
Posts: 9,599

## Re: Array code

...

array in{4} (...);

array out{4} (...);

array dtmin{5} (...);

array dtmax{5} (...);

do i=1 to 4;

do z=1 to 5;

if (dtmin{z} <= in{i} <= dtmax{z}) or (dtmin{z} <= out{i} <= dtmax{z}) then flag="Y";

end;

end;

...

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