<?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 Re: Calculating differences from several columns to identify interruptions in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Calculating-differences-from-several-columns-to-identify/m-p/503333#M134477</link>
    <description>&lt;P&gt;Flag is just an on/off switch to indicate if a . has occured so that missings with a value afterwards has happened.&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 11 Oct 2018 08:46:10 GMT</pubDate>
    <dc:creator>RW9</dc:creator>
    <dc:date>2018-10-11T08:46:10Z</dc:date>
    <item>
      <title>Calculating differences from several columns to identify interruptions</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Calculating-differences-from-several-columns-to-identify/m-p/503321#M134471</link>
      <description>&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;my table looks like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;U&gt;&lt;STRONG&gt;ID Name&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; COL1 COL2 COL3 COL4 COL5&amp;nbsp; COL6&amp;nbsp; ....COL78&lt;/STRONG&gt;&lt;/U&gt;&lt;/P&gt;&lt;P&gt;x&amp;nbsp;&amp;nbsp; MONTH&amp;nbsp;&amp;nbsp;&amp;nbsp; 1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 2&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 3&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; 4 &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 5&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 6&lt;/P&gt;&lt;P&gt;y&amp;nbsp;&amp;nbsp; MONTH&amp;nbsp;&amp;nbsp;&amp;nbsp; 4&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 5&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 6&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; .&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 8&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 9&lt;/P&gt;&lt;P&gt;z &amp;nbsp; MONTH &amp;nbsp;&amp;nbsp; 12 &amp;nbsp; &amp;nbsp; &amp;nbsp; 1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 2 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 3 &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp; .&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; .&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;ID is the variable for the patient and COL consists of the number of the month of a year (12 is December, 1 January....).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So what i want to know is the following:&lt;/P&gt;&lt;P&gt;Are there any interruptions for e.g. patient y regarding the therapy?&lt;/P&gt;&lt;P&gt;And of course there is an interruption (see COL4).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I think first of all i have to calculate the differences between each variable COL2-COL1 COL3-COL2 .... COL78-COL77.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;And then if this difference does not equals 1 there is an interruption (but what is if its December to January 1-12=-11. this also an valid value or if the missing is at the end (patient z) this not an interruption, this the end of the therapy (which is ok)).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Do you have any idea to solve this with an macro or something like this (i have no marco experience at all).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Do you need more information to help me?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you for ur effort!&lt;/P&gt;&lt;P&gt;Mike&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, 11 Oct 2018 07:24:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Calculating-differences-from-several-columns-to-identify/m-p/503321#M134471</guid>
      <dc:creator>Dynamike</dc:creator>
      <dc:date>2018-10-11T07:24:40Z</dc:date>
    </item>
    <item>
      <title>Re: Calculating differences from several columns to identify interruptions</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Calculating-differences-from-several-columns-to-identify/m-p/503323#M134473</link>
      <description>&lt;P&gt;You can use an array and a flag to ascertain this, something like:&lt;/P&gt;
&lt;PRE&gt;data want;
   set have;
   array col{78};
   flag=0;
   missed=0;
   do i=1 to 78;
      if col{i}=. then flag=1;
      else if col{i} ne . and flag=1 then do;
        flag=0;
        missed=sum(missed,1);
     end;
  end;
run; &lt;/PRE&gt;
&lt;P&gt;This should count any instances where . occurs (sets flag) then if a number happens it means there was a gap so add to count.&lt;/P&gt;</description>
      <pubDate>Thu, 11 Oct 2018 07:49:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Calculating-differences-from-several-columns-to-identify/m-p/503323#M134473</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2018-10-11T07:49:08Z</dc:date>
    </item>
    <item>
      <title>Re: Calculating differences from several columns to identify interruptions</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Calculating-differences-from-several-columns-to-identify/m-p/503324#M134474</link>
      <description>Thank you very much for ur quick answer.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;So am i right?: flag=1 could also signify the end of the therapy, BUT if there is missed &amp;gt; 0 there is at least one interruption in between.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;best regards&lt;BR /&gt;&lt;BR /&gt;Mike&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Thu, 11 Oct 2018 08:05:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Calculating-differences-from-several-columns-to-identify/m-p/503324#M134474</guid>
      <dc:creator>Dynamike</dc:creator>
      <dc:date>2018-10-11T08:05:13Z</dc:date>
    </item>
    <item>
      <title>Re: Calculating differences from several columns to identify interruptions</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Calculating-differences-from-several-columns-to-identify/m-p/503330#M134475</link>
      <description>&lt;P&gt;Something like this, perhaps?&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
  set have;
  array cols col1-col78;
  interrupt=n(of cols(*))&amp;gt;0 and missing(col1);
  do _N_=2 to n(of cols(*)) while(not interrupt);
    interrupt=mod(cols(_N_),12) ne mod(cols(_N_-1)+1,12);
    end;
run;

&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Or, if you need to find the place where the first interruption is:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
  set have;
  array cols col1-col78;
  interrupt=n(of cols(*))&amp;gt;0 and missing(col1);
  do _N_=2 to n(of cols(*)) while(not interrupt);
    if mod(cols(_N_),12) ne mod(cols(_N_-1)+1,12) then
      interrupt=_N_;
    end;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 11 Oct 2018 08:24:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Calculating-differences-from-several-columns-to-identify/m-p/503330#M134475</guid>
      <dc:creator>s_lassen</dc:creator>
      <dc:date>2018-10-11T08:24:39Z</dc:date>
    </item>
    <item>
      <title>Re: Calculating differences from several columns to identify interruptions</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Calculating-differences-from-several-columns-to-identify/m-p/503333#M134477</link>
      <description>&lt;P&gt;Flag is just an on/off switch to indicate if a . has occured so that missings with a value afterwards has happened.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 11 Oct 2018 08:46:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Calculating-differences-from-several-columns-to-identify/m-p/503333#M134477</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2018-10-11T08:46:10Z</dc:date>
    </item>
    <item>
      <title>Re: Calculating differences from several columns to identify interruptions</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Calculating-differences-from-several-columns-to-identify/m-p/503385#M134501</link>
      <description>&lt;P&gt;Thank you this works very well!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Now&amp;nbsp; i know there is an interruption and when.&lt;/P&gt;&lt;P&gt;Is it possible to add an information how long the interruption took place?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you in advance!&lt;/P&gt;&lt;P&gt;Mike&lt;/P&gt;</description>
      <pubDate>Thu, 11 Oct 2018 12:49:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Calculating-differences-from-several-columns-to-identify/m-p/503385#M134501</guid>
      <dc:creator>Dynamike</dc:creator>
      <dc:date>2018-10-11T12:49:48Z</dc:date>
    </item>
  </channel>
</rss>

