<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Arrays-using multiple variables against other multiple events in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Arrays-using-multiple-variables-against-other-multiple-events/m-p/420258#M280606</link>
    <description>&lt;P&gt;Hi all;&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Kinda stumped on this and I'll see if I can explain it well&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What I have are patient encounters with multiple catheter insertions and/or multiple surgeries-&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So a patient encounter may be&lt;/P&gt;
&lt;P&gt;PT_ENC_NUMBER&amp;nbsp;CATH_TIME1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;CATH_TIME2&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;SURG_START1&amp;nbsp; &amp;nbsp; &amp;nbsp; SURG_START2&amp;nbsp; &amp;nbsp; &amp;nbsp;SURG_END1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; SURG_END2&lt;/P&gt;
&lt;P&gt;123&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;01JAN17:12:00:00&amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;SPAN&gt;&amp;nbsp;05JAN17:12:00:00 &amp;nbsp;01JAN17:10:00:00&amp;nbsp; 07JAN17:13:00:00 01JAN17:13:00:00&amp;nbsp;07JAN17:17:00&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;So here Cath 1 was inserted in surg 1 but not Surgery2&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Cath2 was not inserted in surgery1 or surgery2. So I know the total number of surgical insertions was 1-&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;All in all, its dynamic but let's say a patient can have up to 30 surgeries and 8 catheter insertions&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;I think I need a multi-dimension array but having some challenges overall;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Any advice appreciated.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Lawrence&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 11 Dec 2017 19:33:37 GMT</pubDate>
    <dc:creator>LB</dc:creator>
    <dc:date>2017-12-11T19:33:37Z</dc:date>
    <item>
      <title>Arrays-using multiple variables against other multiple events</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Arrays-using-multiple-variables-against-other-multiple-events/m-p/420258#M280606</link>
      <description>&lt;P&gt;Hi all;&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Kinda stumped on this and I'll see if I can explain it well&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What I have are patient encounters with multiple catheter insertions and/or multiple surgeries-&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So a patient encounter may be&lt;/P&gt;
&lt;P&gt;PT_ENC_NUMBER&amp;nbsp;CATH_TIME1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;CATH_TIME2&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;SURG_START1&amp;nbsp; &amp;nbsp; &amp;nbsp; SURG_START2&amp;nbsp; &amp;nbsp; &amp;nbsp;SURG_END1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; SURG_END2&lt;/P&gt;
&lt;P&gt;123&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;01JAN17:12:00:00&amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;SPAN&gt;&amp;nbsp;05JAN17:12:00:00 &amp;nbsp;01JAN17:10:00:00&amp;nbsp; 07JAN17:13:00:00 01JAN17:13:00:00&amp;nbsp;07JAN17:17:00&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;So here Cath 1 was inserted in surg 1 but not Surgery2&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Cath2 was not inserted in surgery1 or surgery2. So I know the total number of surgical insertions was 1-&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;All in all, its dynamic but let's say a patient can have up to 30 surgeries and 8 catheter insertions&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;I think I need a multi-dimension array but having some challenges overall;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Any advice appreciated.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Lawrence&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 11 Dec 2017 19:33:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Arrays-using-multiple-variables-against-other-multiple-events/m-p/420258#M280606</guid>
      <dc:creator>LB</dc:creator>
      <dc:date>2017-12-11T19:33:37Z</dc:date>
    </item>
    <item>
      <title>Re: Arrays-using multiple variables against other multiple events</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Arrays-using-multiple-variables-against-other-multiple-events/m-p/420262#M280607</link>
      <description>&lt;P&gt;Hi Lawrence,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My answer assumes&amp;nbsp;that you have the start and end time for every surgery the patient had (aka. matching surg_startx and surg_endx).&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data temp;
   input PT_ENC_NUMBER @@;
   input (CATH_TIME1 CATH_TIME2 SURG_START1 SURG_START2 SURG_END1 SURG_END2) ( :datetime.);
   format CATH_TIME1 CATH_TIME2 SURG_START1 SURG_START2 SURG_END1 SURG_END2 datetime.;
datalines;
123 01JAN17:12:00:00 05JAN17:12:00:00 01JAN17:10:00:00 07JAN17:13:00:00 01JAN17:13:00:00 07JAN17:17:00  
124 10JAN17:12:00:00 15JAN17:12:00:00 01JAN17:10:00:00 07JAN17:13:00:00 01JAN17:13:00:00 07JAN17:17:00  
124 01JAN17:12:00:00 07JAN17:15:00:00 01JAN17:10:00:00 07JAN17:13:00:00 01JAN17:13:00:00 07JAN17:17:00  
;

run;

data solution;
   set temp;

   array caths  [*] cath:       ;
   array surg_s [*] surg_start: ;
   array surg_e [*] surg_end:   ;

   total=0;
   do i = 1 to dim(caths);
      do j = 1 to dim(surg_s);
         if surg_s[j]&amp;lt;=caths[i]&amp;lt;=surg_e[j] then total+1;
      end;
   end;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 11 Dec 2017 20:09:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Arrays-using-multiple-variables-against-other-multiple-events/m-p/420262#M280607</guid>
      <dc:creator>antonbcristina</dc:creator>
      <dc:date>2017-12-11T20:09:49Z</dc:date>
    </item>
    <item>
      <title>Re: Arrays-using multiple variables against other multiple events</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Arrays-using-multiple-variables-against-other-multiple-events/m-p/420272#M280608</link>
      <description>&lt;P&gt;You don't really show any desired result or explained it very clearly&amp;nbsp;so I'll be guessing here.&lt;/P&gt;
&lt;P&gt;I suspect that you want&amp;nbsp;3 separate arrays for the comparisons, one that would be the catheter times and the second the surgery start and the last the surgery end_end&amp;nbsp;times.&lt;/P&gt;
&lt;P&gt;Depending upon the desired result something like this may get you started. This assumes none of the surgery start/end pairs overlap and that the insertion occurs within a single interval and that all of your datetime variables are SAS valued datetimes. If they are character this won't work.&lt;/P&gt;
&lt;PRE&gt;data example;
   set have;
   array c cath_time: ;
   array ss surg_start: ;
   array se surg_end;
   array ws {8}; /* this willl hold which surgery had an insertion number MUST
                 match number of cath_time variables*/
   do 1 = 1 to dim(ss);
      do j= 1 to dim(c);
         if ss[i] le c[j] le se[i] then do;
            /* found an insertion in the ith surgery for the jth cath*/
            ws [j] = i;
         end;
      end;
   End;
   /* if you want a total number of cath insertions*/
   NumInsert = n(of ws(*));

run;&lt;/PRE&gt;</description>
      <pubDate>Mon, 11 Dec 2017 20:21:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Arrays-using-multiple-variables-against-other-multiple-events/m-p/420272#M280608</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2017-12-11T20:21:31Z</dc:date>
    </item>
    <item>
      <title>Re: Arrays-using multiple variables against other multiple events</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Arrays-using-multiple-variables-against-other-multiple-events/m-p/420281#M280609</link>
      <description>&lt;P&gt;Ballard;&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;As I said I having some trouble articulating what the results I was trying to get but you nailed 99.9% of the way there. I had to make a minor change but saved me a lot of hours spinning my wheels!&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks again-I love this forum!&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Lawrence&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 11 Dec 2017 20:46:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Arrays-using-multiple-variables-against-other-multiple-events/m-p/420281#M280609</guid>
      <dc:creator>LB</dc:creator>
      <dc:date>2017-12-11T20:46:12Z</dc:date>
    </item>
    <item>
      <title>Re: Arrays-using multiple variables against other multiple events</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Arrays-using-multiple-variables-against-other-multiple-events/m-p/421128#M280610</link>
      <description>&lt;P&gt;Ok Ballardw I am back with a follow up question-&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So I have expanded the array a bit and everything works pretty well except for the components in red. I can tell by manually comparing the data.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The expanded version not just looks if the catheter was placed during a surgery but also there is a binary flag to whether that surgery was under 4 hours.&amp;nbsp; SO now I need surgeries whether catheter was placed in OR and another array to tell me if catheter was placed in OR and surgery was &amp;lt;4 hours. The array that calculates&amp;nbsp; whether it was done in surgery works great (Thank you again)&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have tried different combinations to no avail.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data hairyarray;&lt;BR /&gt;retain cath_day SURG SURG_INSERT POD surg_under4hr SURG_INSERT4HR ED_STAY INPT_INSERTION;&lt;BR /&gt; merge toarray final_cath_transpo final_surg_transpo final_cath_transpo_placement;&lt;BR /&gt;by pat_enc_csn_id;&lt;/P&gt;
&lt;P&gt;array c START_DT: ; /*ARRAY FOR THE CATH START TIMES*/ &lt;BR /&gt;array ce END_DT: ; /*ARRAY FOR THE CATH END TIMES*/ &lt;BR /&gt;array ss LOG_PAT_IN_ROOM_TIME: ; /*ARRAY FOR THE SURG START TIMES*/&lt;BR /&gt;array se LOG_PAT_OUT_OF_ROOM_TIME: ; /*ARRAY FOR SURG END TIMES*/&lt;BR /&gt;&lt;FONT color="#FF0000"&gt;array Surgfour surg_under4hr: ; /*ARRAY FOR THE SURG FOR UNDER 4 HOURS*/&lt;/FONT&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;array ws {&amp;amp;finalcath} ; /*ARRAY TO DETERMINE IF CATH PLACED IN OR*/&lt;BR /&gt;array podx {&amp;amp;finalcath} ; /*ARRAY TO DETERMINE IF CATH REMOVED POD1*/&lt;BR /&gt;array surgx{&amp;amp;finalsurgc} ;/*ARRAY TO COUNTS NUMBER OF SURGERIES*/&lt;BR /&gt;&lt;FONT color="#FF0000"&gt;array SURGfouri{&amp;amp;finalcath} ;/*ARRAY TO DETERMINE IF CATH PLACED IN OR AND SURG UNDER 4 HOURS*/&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt; do i = 1 to dim(ss);&lt;/P&gt;
&lt;P&gt;do j= 1 to dim(c);&lt;BR /&gt; if ss[i] le c[j] le se[i] then do;&lt;BR /&gt; &lt;BR /&gt; ws [j] = i;&lt;BR /&gt;if ws [j] = &amp;amp;finalsurgc then ws [j]=.; &lt;SPAN&gt;/*DELETES INCORRECT ENTRIES*/&lt;/SPAN&gt;&lt;BR /&gt; &lt;FONT color="#FF0000"&gt;&amp;nbsp;if&amp;nbsp;&lt;SPAN&gt;ws [j]=i&amp;nbsp;and&amp;nbsp;&lt;/SPAN&gt; Surgfour[i]^=. then SURGfouri[j]=i;&lt;/FONT&gt;&lt;BR /&gt; if ws [j]^=. and intck('dtday', se[i],ce[j])&amp;lt;2 then podx[j]=i; /*THIS GETS WHETHER IT WAS POD1 OR NO*/ &lt;BR /&gt; if podx[j]=&amp;amp;finalsurgc-1 then podx[j]=.; /*DELETES INCORRECT ENTRIES*/&lt;BR /&gt;&lt;BR /&gt;end;&lt;/P&gt;
&lt;P&gt;if ss[i] ^=. then surgx[i]=1; /*COUNTS THE SURGERIES*/&lt;BR /&gt;if SURGfouri[j]&amp;gt;n(of surgx(*)) then SURGfouri[j]=.;&amp;nbsp;&amp;nbsp;&lt;BR /&gt;end;&lt;BR /&gt; end;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt; ; /*TOTALS NUMBEROF SURGICAL INSERTIONS*/&lt;BR /&gt;POD = n(of PODx(*)); /*TOTALS NUMBER OF POD1 REMOVALS*/&lt;BR /&gt;SURG=n(of surgx(*)); /*TOTALS NUMBER OF SURGERIES*/&lt;BR /&gt;SURG_INSERT = n(of ws(*)); /*TOTALS NUMBER OF SURGICAL INSERTIONS*/&lt;BR /&gt;SURG_INSERT4HR=n(of SURGfouri(*)); /*TOTALS NUMBER OF SURGICAL INSERTIONS &amp;lt;4 HRS*/&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks for&amp;nbsp; your time again.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Lawrence&lt;/P&gt;
&lt;P&gt;(ps If I am not making sense I apologize it's late)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 14 Dec 2017 09:55:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Arrays-using-multiple-variables-against-other-multiple-events/m-p/421128#M280610</guid>
      <dc:creator>LB</dc:creator>
      <dc:date>2017-12-14T09:55:00Z</dc:date>
    </item>
  </channel>
</rss>

