Help using Base SAS procedures

Array code

Reply
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

Respected Advisor
Posts: 4,173

Re: Array code

Posted in reply to robertrao

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
Super User
Posts: 7,975

Re: Array code

Posted in reply to robertrao

...

  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;

...

Ask a Question
Discussion stats
  • 2 replies
  • 177 views
  • 0 likes
  • 3 in conversation