BookmarkSubscribeRSS Feed
robertrao
Quartz | Level 8

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

2 REPLIES 2
Patrick
Opal | Level 21

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.

RW9
Diamond | Level 26 RW9
Diamond | Level 26

...

  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;

...

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

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