<?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: Horizontal count of Number of variables criteria consecutively in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Horizontal-count-of-Number-of-variables-criteria-consecutively/m-p/792850#M81501</link>
    <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input (var1-var13)($);
cards;
Y Y N N Y Y Y N Y Y Y N N
Y Y Y Y Y Y Y Y Y Y N N N
Y N N N N Y N N Y Y Y N N
;
run;

data want;
 set have;
length temp $ 2000;
temp=cats(of var1-var10);

pid=prxparse('/Y+/o');
s=1;e=length(temp);want=0;
call prxnext(pid,s,e,temp,p,l);
do while(p&amp;gt;0);
 want=max(want,l);
 call prxnext(pid,s,e,temp,p,l);
end;

drop temp pid s e p l ;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Thu, 27 Jan 2022 13:35:00 GMT</pubDate>
    <dc:creator>Ksharp</dc:creator>
    <dc:date>2022-01-27T13:35:00Z</dc:date>
    <item>
      <title>Horizontal count of Number of variables criteria consecutively</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Horizontal-count-of-Number-of-variables-criteria-consecutively/m-p/792547#M81498</link>
      <description>&lt;P&gt;I have a data set and I am trying to count how often this repeats consecutively across a particular volume of variables.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have shown an example of what I have in the below dataset which has 13 variables, but i am looking at seeing how many Consecutive "Y"'s happen within a particular section. E.g. The example is from Var1-10 but this may change to look at between Var2-8 depending on requirements etc.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data have;&lt;BR /&gt;input (var1-var13)($);&lt;BR /&gt;cards;&lt;BR /&gt;Y Y N N Y Y Y N Y Y Y N N&lt;BR /&gt;Y Y Y Y Y Y Y Y Y Y N N N&lt;BR /&gt;Y N N N N Y N N Y Y Y N N&lt;BR /&gt;;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Below you can see this count conservative Y's and output the largest volume the between var 1-10 giving the largest consecutive outcome between them in the final column. Is this possible to do?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data Want;&lt;BR /&gt;input (var1-var13)($) Total_Consecutive_Y_10vars;&lt;BR /&gt;cards;&lt;BR /&gt;Y Y N N Y Y Y N Y Y Y N N 3&lt;BR /&gt;Y Y Y Y Y Y Y Y Y Y N N N 10&lt;BR /&gt;Y N N N N Y N N N Y Y N N 1&lt;BR /&gt;;&lt;BR /&gt;run;&lt;/P&gt;</description>
      <pubDate>Wed, 26 Jan 2022 17:08:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Horizontal-count-of-Number-of-variables-criteria-consecutively/m-p/792547#M81498</guid>
      <dc:creator>Mick_bill</dc:creator>
      <dc:date>2022-01-26T17:08:40Z</dc:date>
    </item>
    <item>
      <title>Re: Horizontal count of Number of variables criteria consecutively</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Horizontal-count-of-Number-of-variables-criteria-consecutively/m-p/792850#M81501</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input (var1-var13)($);
cards;
Y Y N N Y Y Y N Y Y Y N N
Y Y Y Y Y Y Y Y Y Y N N N
Y N N N N Y N N Y Y Y N N
;
run;

data want;
 set have;
length temp $ 2000;
temp=cats(of var1-var10);

pid=prxparse('/Y+/o');
s=1;e=length(temp);want=0;
call prxnext(pid,s,e,temp,p,l);
do while(p&amp;gt;0);
 want=max(want,l);
 call prxnext(pid,s,e,temp,p,l);
end;

drop temp pid s e p l ;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 27 Jan 2022 13:35:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Horizontal-count-of-Number-of-variables-criteria-consecutively/m-p/792850#M81501</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2022-01-27T13:35:00Z</dc:date>
    </item>
  </channel>
</rss>

