<?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: Row calculations in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Row-calculations/m-p/675416#M203511</link>
    <description>&lt;P&gt;Normally to work with a series of variables you would use an ARRAY statement to allow you use an index.&lt;/P&gt;
&lt;P&gt;In this simple case I would just convert the values to a string and use some simple pattern matching.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
  input Student_id $ Week1-Week6;
cards;
123 0 4 3 0 0 2
124 4 3 4 4 4 4
125 2 0 0 3 2 1
126 0 2 3 0 2 0
127 0 0 0 0 0 0
;

data want;
  set have;
  if indexw(catx(' ',of week1-week6),'0 0');
run;

proc print;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;PRE&gt;       Student_
Obs       id       Week1    Week2    Week3    Week4    Week5    Week6

 1       123         0        4        3        0        0        2
 2       125         2        0        0        3        2        1
 3       127         0        0        0        0        0        0
&lt;/PRE&gt;</description>
    <pubDate>Sat, 08 Aug 2020 17:50:23 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2020-08-08T17:50:23Z</dc:date>
    <item>
      <title>Row calculations</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Row-calculations/m-p/675413#M203508</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I have the following data set:&lt;/P&gt;&lt;P&gt;Student_id&amp;nbsp; &amp;nbsp; &amp;nbsp;Week1&amp;nbsp; Week2&amp;nbsp; Week3&amp;nbsp; Week4&amp;nbsp; Week5&amp;nbsp; Week6&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;0&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;3&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;0&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 0&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 2&lt;/P&gt;&lt;P&gt;124&amp;nbsp; &amp;nbsp; &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; &amp;nbsp;3&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;4&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 4&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 4&amp;nbsp;&lt;/P&gt;&lt;P&gt;125&amp;nbsp; &amp;nbsp; &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;0&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;0&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;3&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 2&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1&lt;/P&gt;&lt;P&gt;126&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;0&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;3&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;0&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;0&lt;/P&gt;&lt;P&gt;127&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;0&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;0&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;0&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;0&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 0&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 0&lt;/P&gt;&lt;P&gt;0 means that the person didn't attend any classes in that week, 1/2/3 means how many classes student attended in the week. I need to produce a report with students who didn't attend any classes for at least 2 weeks in a row. Does anyone have an idea how to do it? Thank you for your help.&lt;/P&gt;</description>
      <pubDate>Sat, 08 Aug 2020 17:18:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Row-calculations/m-p/675413#M203508</guid>
      <dc:creator>weronikaz</dc:creator>
      <dc:date>2020-08-08T17:18:27Z</dc:date>
    </item>
    <item>
      <title>Re: Row calculations</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Row-calculations/m-p/675416#M203511</link>
      <description>&lt;P&gt;Normally to work with a series of variables you would use an ARRAY statement to allow you use an index.&lt;/P&gt;
&lt;P&gt;In this simple case I would just convert the values to a string and use some simple pattern matching.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
  input Student_id $ Week1-Week6;
cards;
123 0 4 3 0 0 2
124 4 3 4 4 4 4
125 2 0 0 3 2 1
126 0 2 3 0 2 0
127 0 0 0 0 0 0
;

data want;
  set have;
  if indexw(catx(' ',of week1-week6),'0 0');
run;

proc print;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;PRE&gt;       Student_
Obs       id       Week1    Week2    Week3    Week4    Week5    Week6

 1       123         0        4        3        0        0        2
 2       125         2        0        0        3        2        1
 3       127         0        0        0        0        0        0
&lt;/PRE&gt;</description>
      <pubDate>Sat, 08 Aug 2020 17:50:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Row-calculations/m-p/675416#M203511</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2020-08-08T17:50:23Z</dc:date>
    </item>
    <item>
      <title>Re: Row calculations</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Row-calculations/m-p/675417#M203512</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/340121"&gt;@weronikaz&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
data have;
input Student_id     Week1  Week2  Week3  Week4  Week5  Week6;
cards;
123                   0             4           3           0          0            2
124                   4             3           4           4          4            4 
125                   2             0           0           3          2            1
126                   0             2           3           0          2             0
127                   0             0           0           0          0            0
;

data want;
 set have;
 array t week:;
 _n_=countw(cats(of t(*)),'0','k');
 do _n_=1 to _n_;
  if lengthn(scan(cats(of t(*)),_n_,'0','k'))&amp;gt;=2 then do;
   output;
   leave;
  end;
 end;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;DIV class="branch"&gt;
&lt;DIV&gt;
&lt;DIV align="center"&gt;
&lt;TABLE class="table" summary="Procedure Print: Data Set WORK.WANT1" frame="box" rules="all" cellspacing="0" cellpadding="5"&gt;&lt;COLGROUP&gt; &lt;COL /&gt; &lt;COL /&gt; &lt;COL /&gt; &lt;COL /&gt; &lt;COL /&gt; &lt;COL /&gt; &lt;COL /&gt;&lt;/COLGROUP&gt;
&lt;THEAD&gt;
&lt;TR&gt;
&lt;TH class="r header" scope="col"&gt;Student_id&lt;/TH&gt;
&lt;TH class="r header" scope="col"&gt;Week1&lt;/TH&gt;
&lt;TH class="r header" scope="col"&gt;Week2&lt;/TH&gt;
&lt;TH class="r header" scope="col"&gt;Week3&lt;/TH&gt;
&lt;TH class="r header" scope="col"&gt;Week4&lt;/TH&gt;
&lt;TH class="r header" scope="col"&gt;Week5&lt;/TH&gt;
&lt;TH class="r header" scope="col"&gt;Week6&lt;/TH&gt;
&lt;/TR&gt;
&lt;/THEAD&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD class="r data"&gt;123&lt;/TD&gt;
&lt;TD class="r data"&gt;0&lt;/TD&gt;
&lt;TD class="r data"&gt;4&lt;/TD&gt;
&lt;TD class="r data"&gt;3&lt;/TD&gt;
&lt;TD class="r data"&gt;0&lt;/TD&gt;
&lt;TD class="r data"&gt;0&lt;/TD&gt;
&lt;TD class="r data"&gt;2&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="r data"&gt;125&lt;/TD&gt;
&lt;TD class="r data"&gt;2&lt;/TD&gt;
&lt;TD class="r data"&gt;0&lt;/TD&gt;
&lt;TD class="r data"&gt;0&lt;/TD&gt;
&lt;TD class="r data"&gt;3&lt;/TD&gt;
&lt;TD class="r data"&gt;2&lt;/TD&gt;
&lt;TD class="r data"&gt;1&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="r data"&gt;127&lt;/TD&gt;
&lt;TD class="r data"&gt;0&lt;/TD&gt;
&lt;TD class="r data"&gt;0&lt;/TD&gt;
&lt;TD class="r data"&gt;0&lt;/TD&gt;
&lt;TD class="r data"&gt;0&lt;/TD&gt;
&lt;TD class="r data"&gt;0&lt;/TD&gt;
&lt;TD class="r data"&gt;0&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;</description>
      <pubDate>Sat, 08 Aug 2020 17:54:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Row-calculations/m-p/675417#M203512</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2020-08-08T17:54:18Z</dc:date>
    </item>
    <item>
      <title>Re: Row calculations</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Row-calculations/m-p/675420#M203514</link>
      <description>just be sure no one ever attends 10 classes anytime except week 6.</description>
      <pubDate>Sat, 08 Aug 2020 18:18:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Row-calculations/m-p/675420#M203514</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2020-08-08T18:18:26Z</dc:date>
    </item>
    <item>
      <title>Re: Row calculations</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Row-calculations/m-p/675422#M203516</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/31461"&gt;@mkeintz&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;just be sure no one ever attends 10 classes anytime except week 6.&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;That wouldn't make any difference.&amp;nbsp; Notice the use of INDEXW().&lt;/P&gt;
&lt;P&gt;It might catch 0 followed by 0.5 but only if you include period in addition to space in list of delimiters in the INDEXW() call.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 08 Aug 2020 19:48:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Row-calculations/m-p/675422#M203516</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2020-08-08T19:48:09Z</dc:date>
    </item>
    <item>
      <title>Re: Row calculations</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Row-calculations/m-p/675430#M203521</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
   


data have;
input Student_id     Week1  Week2  Week3  Week4  Week5  Week6;
cards;
123                   0             4           3           0          0            2
124                   4             3           4           4          4            4 
125                   2             0           0           3          2            1
126                   0             2           3           0          2             0
127                   0             0           0           0          0            0
;


data want;
 set have;
 if prxmatch('/(0){2,}/', cats(of week1-week6));
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 08 Aug 2020 19:43:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Row-calculations/m-p/675430#M203521</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2020-08-08T19:43:34Z</dc:date>
    </item>
    <item>
      <title>Re: Row calculations</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Row-calculations/m-p/675470#M203539</link>
      <description>&lt;PRE&gt;data have;
input Student_id     Week1  Week2  Week3  Week4  Week5  Week6;
cards;
123                   0             4           3           0          0            2
124                   4             3           4           4          4            4 
125                   2             0           0           3          2            1
126                   0             2           3           0          2             0
127                   0             0           0           0          0            0
;
data want;
 set have;
 array x{*} week: ;
 do _n_=1 to dim(x)-1;
  if x{_n_}=0 and x{_n_+1}=0 then do;output;leave;end;
 end;
run;&lt;/PRE&gt;</description>
      <pubDate>Sun, 09 Aug 2020 11:33:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Row-calculations/m-p/675470#M203539</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2020-08-09T11:33:48Z</dc:date>
    </item>
  </channel>
</rss>

