<?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: count in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/count/m-p/353791#M82610</link>
    <description>Thank you, we need to consider the &amp;gt;= 2 continuous 0 instead of total 0 . For example, there are two 0 for ID 1, but it cannot be deleted, due to not 0 is separated.</description>
    <pubDate>Wed, 26 Apr 2017 17:18:25 GMT</pubDate>
    <dc:creator>Ivy</dc:creator>
    <dc:date>2017-04-26T17:18:25Z</dc:date>
    <item>
      <title>count</title>
      <link>https://communities.sas.com/t5/SAS-Programming/count/m-p/353767#M82597</link>
      <description>&lt;P&gt;Hello,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I would like to delete the ID with more than 2 coutinous 0 value of RX. I am wondering what is efficient way to do it. &amp;nbsp; Thank you very much.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;ID &amp;nbsp; &amp;nbsp;RX &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;1&lt;/P&gt;&lt;P&gt;1 &amp;nbsp; &amp;nbsp; &amp;nbsp; 1&lt;/P&gt;&lt;P&gt;1 &amp;nbsp; &amp;nbsp; &amp;nbsp; 0&lt;/P&gt;&lt;P&gt;1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;1&lt;/P&gt;&lt;P&gt;1 &amp;nbsp; &amp;nbsp; &amp;nbsp; 0&lt;/P&gt;&lt;P&gt;1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;1&lt;/P&gt;&lt;P&gt;2 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;0&lt;/P&gt;&lt;P&gt;2 &amp;nbsp; &amp;nbsp; &amp;nbsp; 0&lt;/P&gt;&lt;P&gt;2 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;1&lt;/P&gt;</description>
      <pubDate>Wed, 26 Apr 2017 17:16:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/count/m-p/353767#M82597</guid>
      <dc:creator>Ivy</dc:creator>
      <dc:date>2017-04-26T17:16:20Z</dc:date>
    </item>
    <item>
      <title>Re: count</title>
      <link>https://communities.sas.com/t5/SAS-Programming/count/m-p/353775#M82604</link>
      <description>&lt;P&gt;I prefer proc sql because the code/concept may be used in many applications.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For your consideration:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;PROC SQL;
CREATE TABLE TOTALS AS
SELECT ID, SUM(RX) AS TOTAL FROM IDS GROUP BY ID;
QUIT;

PROC SQL;
CREATE TABLE NEWTABLE AS
SELECT * FROM IDS WHERE ID IN (SELECT ID FROM TOTALS WHERE TOTAL &amp;lt;=2);
QUIT;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 26 Apr 2017 16:12:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/count/m-p/353775#M82604</guid>
      <dc:creator>thomp7050</dc:creator>
      <dc:date>2017-04-26T16:12:19Z</dc:date>
    </item>
    <item>
      <title>Re: count</title>
      <link>https://communities.sas.com/t5/SAS-Programming/count/m-p/353791#M82610</link>
      <description>Thank you, we need to consider the &amp;gt;= 2 continuous 0 instead of total 0 . For example, there are two 0 for ID 1, but it cannot be deleted, due to not 0 is separated.</description>
      <pubDate>Wed, 26 Apr 2017 17:18:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/count/m-p/353791#M82610</guid>
      <dc:creator>Ivy</dc:creator>
      <dc:date>2017-04-26T17:18:25Z</dc:date>
    </item>
    <item>
      <title>Re: count</title>
      <link>https://communities.sas.com/t5/SAS-Programming/count/m-p/353793#M82611</link>
      <description>&lt;P&gt;So want to look for two in a row? &amp;nbsp;You didn't mention any variable to use for ordering so we should we assume the data is already sorted? &amp;nbsp;&lt;/P&gt;
&lt;P&gt;So two is easy. Basically if RX=0 and it is not an isolated block of just one RX=0 then you have two or more RX=0 records in a row.&lt;/P&gt;
&lt;P&gt;Using double DOW loop you can test an ID and then in the second loop decide whether to output the records for that ID.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want ;
 do until (last.id);
   set have ;
   by id rx notsorted ;
   if rx=0 and not (first.rx and last.rx) then any2=1;
 end;
 do until (last.id);
   set have ;
   by id rx notsorted ;
   if not any2 then output;
 end;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;It looks like both of your example IDs would be deleted since the both have two or more RX=0 records next to each other.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 26 Apr 2017 17:20:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/count/m-p/353793#M82611</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2017-04-26T17:20:18Z</dc:date>
    </item>
  </channel>
</rss>

