<?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: how to delete  row observations in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/how-to-delete-row-observations/m-p/339527#M77457</link>
    <description>&lt;P&gt;Here is one way to do it:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;data want;
  do until (last.company);
    set new;
    by company;
    if first.company then do;
      _have0=0;
      _have1=0;
    end;
    if forecast=1 then have1=1;
    else if forecast=0 then have0=1;
  end;
  do until (last.company);
    set new;
    by company;
    if have0 and have1 then output;
  end;
run;
&lt;/PRE&gt;
&lt;P&gt;HTH,&lt;/P&gt;
&lt;P&gt;Art, CEO, AnalystFinder.com&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 09 Mar 2017 03:32:51 GMT</pubDate>
    <dc:creator>art297</dc:creator>
    <dc:date>2017-03-09T03:32:51Z</dc:date>
    <item>
      <title>how to delete  row observations</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-delete-row-observations/m-p/339519#M77456</link>
      <description>&lt;P&gt;hello&lt;/P&gt;&lt;P&gt;my data like this&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data new;
input company$ forecast yymm;
cards;
A 1 198503
A 1 195503
A 0 198503
A 0 198504
A 1 198504
B 1 198503
B 1 198503
B 1 198504
C 0 198504
C 1 198504
;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;There is no missing data. I would like to every &amp;nbsp;observation in every date has &amp;nbsp;the variable '0,1'. If can not, the observation should be deleted. For example, A in &amp;nbsp;198503 and in 198504 which both have variable ‘0&amp;amp;1’ &amp;nbsp;should be kept, while B in 198504 which only has variable '0' &amp;nbsp;should be deleted. So the result should only remain observation A.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks a lot.&lt;/P&gt;</description>
      <pubDate>Thu, 09 Mar 2017 03:26:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-delete-row-observations/m-p/339519#M77456</guid>
      <dc:creator>lixuan</dc:creator>
      <dc:date>2017-03-09T03:26:08Z</dc:date>
    </item>
    <item>
      <title>Re: how to delete  row observations</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-delete-row-observations/m-p/339527#M77457</link>
      <description>&lt;P&gt;Here is one way to do it:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;data want;
  do until (last.company);
    set new;
    by company;
    if first.company then do;
      _have0=0;
      _have1=0;
    end;
    if forecast=1 then have1=1;
    else if forecast=0 then have0=1;
  end;
  do until (last.company);
    set new;
    by company;
    if have0 and have1 then output;
  end;
run;
&lt;/PRE&gt;
&lt;P&gt;HTH,&lt;/P&gt;
&lt;P&gt;Art, CEO, AnalystFinder.com&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 09 Mar 2017 03:32:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-delete-row-observations/m-p/339527#M77457</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2017-03-09T03:32:51Z</dc:date>
    </item>
    <item>
      <title>Re: how to delete  row observations</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-delete-row-observations/m-p/339530#M77459</link>
      <description>&lt;P&gt;Another way:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql; 
  select src.*
    from HAVE          src
        ,(select COMPANY, YYMM, count(unique(FORECAST)) as C
          from HAVE
          group by 1,2
          having C=2)  vet
    where src.COMPANY=vet.COMPANY 
        &amp;amp; src.YYMM   =vet.YYMM;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 09 Mar 2017 03:59:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-delete-row-observations/m-p/339530#M77459</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2017-03-09T03:59:26Z</dc:date>
    </item>
    <item>
      <title>Re: how to delete  row observations</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-delete-row-observations/m-p/339533#M77461</link>
      <description>&lt;P&gt;Hi, thank you very much , but C should also be deleted, because C don't have '0&amp;amp;1' in 198503. Thanks again.&lt;/P&gt;</description>
      <pubDate>Thu, 09 Mar 2017 04:08:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-delete-row-observations/m-p/339533#M77461</guid>
      <dc:creator>lixuan</dc:creator>
      <dc:date>2017-03-09T04:08:44Z</dc:date>
    </item>
    <item>
      <title>Re: how to delete  row observations</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-delete-row-observations/m-p/339534#M77462</link>
      <description>&lt;P&gt;Also, all observations of A should be kept. Thanks&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 09 Mar 2017 04:15:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-delete-row-observations/m-p/339534#M77462</guid>
      <dc:creator>lixuan</dc:creator>
      <dc:date>2017-03-09T04:15:11Z</dc:date>
    </item>
    <item>
      <title>Re: how to delete  row observations</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-delete-row-observations/m-p/339541#M77465</link>
      <description>&lt;P&gt;In this case, you havent explained you logic properly.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Are you saying that company A should be kept because it includes, somewhere in its records, all 4 dates and all 2 forecasts? regardless of any crossing between date and forecast?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If so, how do we get the list of all dates to check against in order for a company to be kept?&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, 09 Mar 2017 04:45:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-delete-row-observations/m-p/339541#M77465</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2017-03-09T04:45:47Z</dc:date>
    </item>
    <item>
      <title>Re: how to delete  row observations</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-delete-row-observations/m-p/339545#M77468</link>
      <description>&lt;P&gt;c had 2 records, one with a 1, and the 2nd with a 0. That is why the code kept both a and c.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Art, CEO, AnalystFinder.com&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 09 Mar 2017 05:46:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-delete-row-observations/m-p/339545#M77468</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2017-03-09T05:46:10Z</dc:date>
    </item>
    <item>
      <title>Re: how to delete  row observations</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-delete-row-observations/m-p/340029#M77664</link>
      <description>&lt;P&gt;I really appreciate all of you. My problem has been resolve. Thank you&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 10 Mar 2017 16:32:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-delete-row-observations/m-p/340029#M77664</guid>
      <dc:creator>lixuan</dc:creator>
      <dc:date>2017-03-10T16:32:25Z</dc:date>
    </item>
  </channel>
</rss>

