<?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 if data for any row missing then delete whole group in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/if-data-for-any-row-missing-then-delete-whole-group/m-p/511552#M2188</link>
    <description>&lt;PRE&gt;data work.delete;
input firm $ year profit;
datalines;&lt;BR /&gt;A 2001 90&lt;BR /&gt;A 2002 80&lt;BR /&gt;A 2003 70&lt;BR /&gt;A 2004 90&lt;BR /&gt;A 2005 60&lt;BR /&gt;B 2001 70&lt;BR /&gt;B 2002 80&lt;BR /&gt;B 2003 90&lt;BR /&gt;C 2001 70&lt;BR /&gt;C 2002 80&lt;BR /&gt;C 2003 90&lt;BR /&gt;C 2004 60&lt;BR /&gt;C 2005 80&lt;BR /&gt;D 2001 10&lt;BR /&gt;D 2002 20&lt;BR /&gt;&lt;BR /&gt;I wish to delete those firms that does not have observation for 5 years. My desired output is&lt;BR /&gt;A 2001 90&lt;BR /&gt;A 2002 80&lt;BR /&gt;A 2003 70&lt;BR /&gt;A 2004 90&lt;BR /&gt;A 2005 60&lt;BR /&gt;C 2001 70&lt;BR /&gt;C 2002 80&lt;BR /&gt;C 2003 90&lt;BR /&gt;C 2004 60&lt;BR /&gt;C 2005 80&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/PRE&gt;</description>
    <pubDate>Thu, 08 Nov 2018 21:55:27 GMT</pubDate>
    <dc:creator>Takdir</dc:creator>
    <dc:date>2018-11-08T21:55:27Z</dc:date>
    <item>
      <title>if data for any row missing then delete whole group</title>
      <link>https://communities.sas.com/t5/New-SAS-User/if-data-for-any-row-missing-then-delete-whole-group/m-p/511552#M2188</link>
      <description>&lt;PRE&gt;data work.delete;
input firm $ year profit;
datalines;&lt;BR /&gt;A 2001 90&lt;BR /&gt;A 2002 80&lt;BR /&gt;A 2003 70&lt;BR /&gt;A 2004 90&lt;BR /&gt;A 2005 60&lt;BR /&gt;B 2001 70&lt;BR /&gt;B 2002 80&lt;BR /&gt;B 2003 90&lt;BR /&gt;C 2001 70&lt;BR /&gt;C 2002 80&lt;BR /&gt;C 2003 90&lt;BR /&gt;C 2004 60&lt;BR /&gt;C 2005 80&lt;BR /&gt;D 2001 10&lt;BR /&gt;D 2002 20&lt;BR /&gt;&lt;BR /&gt;I wish to delete those firms that does not have observation for 5 years. My desired output is&lt;BR /&gt;A 2001 90&lt;BR /&gt;A 2002 80&lt;BR /&gt;A 2003 70&lt;BR /&gt;A 2004 90&lt;BR /&gt;A 2005 60&lt;BR /&gt;C 2001 70&lt;BR /&gt;C 2002 80&lt;BR /&gt;C 2003 90&lt;BR /&gt;C 2004 60&lt;BR /&gt;C 2005 80&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 08 Nov 2018 21:55:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/if-data-for-any-row-missing-then-delete-whole-group/m-p/511552#M2188</guid>
      <dc:creator>Takdir</dc:creator>
      <dc:date>2018-11-08T21:55:27Z</dc:date>
    </item>
    <item>
      <title>Re: if data for any row missing then delete whole group</title>
      <link>https://communities.sas.com/t5/New-SAS-User/if-data-for-any-row-missing-then-delete-whole-group/m-p/511554#M2189</link>
      <description>&lt;P&gt;This approach assumes your data is sorted by FIRM:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data want;&lt;/P&gt;
&lt;P&gt;counter=0;&lt;/P&gt;
&lt;P&gt;do until (last.firm);&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;set have;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;by firm;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;counter + 1;&lt;/P&gt;
&lt;P&gt;end;&lt;/P&gt;
&lt;P&gt;do until (last.firm);&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;set have;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;by firm;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;if counter &amp;gt;= 5 then output;&lt;/P&gt;
&lt;P&gt;end;&lt;/P&gt;
&lt;P&gt;drop counter;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The top loop counts observations, and the bottom reads the same observations and outputs appropriately.&lt;/P&gt;</description>
      <pubDate>Thu, 08 Nov 2018 22:16:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/if-data-for-any-row-missing-then-delete-whole-group/m-p/511554#M2189</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2018-11-08T22:16:28Z</dc:date>
    </item>
    <item>
      <title>Re: if data for any row missing then delete whole group</title>
      <link>https://communities.sas.com/t5/New-SAS-User/if-data-for-any-row-missing-then-delete-whole-group/m-p/511559#M2190</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data work.delete;
input firm $ year profit;
datalines;
A 2001 90
A 2002 80
A 2003 70
A 2004 90
A 2005 60
B 2001 70
B 2002 80
B 2003 90
C 2001 70
C 2002 80
C 2003 90
C 2004 60
C 2005 80
D 2001 10
D 2002 20
;

proc sql;
create table want as
select *
from delete
group by firm
having count(distinct year)&amp;gt;=5;
quit;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 08 Nov 2018 22:34:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/if-data-for-any-row-missing-then-delete-whole-group/m-p/511559#M2190</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2018-11-08T22:34:04Z</dc:date>
    </item>
    <item>
      <title>Re: if data for any row missing then delete whole group</title>
      <link>https://communities.sas.com/t5/New-SAS-User/if-data-for-any-row-missing-then-delete-whole-group/m-p/511561#M2191</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
data work.delete;
input firm $ year profit;
datalines;
A 2001 90
A 2002 80
A 2003 70
A 2004 90
A 2005 60
B 2001 70
B 2002 80
B 2003 90
C 2001 70
C 2002 80
C 2003 90
C 2004 60
C 2005 80
D 2001 10
D 2002 20
;
data _null_;
if _n_=1 then do;
   dcl hash H (dataset:'delete',ordered: "A", multidata:'y') ;
   h.definekey  ("firm") ;
   h.definedata (all:'y') ;
   h.definedone () ;
end;
  _n_=0;
do until(last.firm);
set delete end=lr;
by firm year;
if first.year then _n_+1;
end;
if _n_&amp;lt;5 then h.remove();
if lr then h.output(dataset:'want');
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 08 Nov 2018 22:41:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/if-data-for-any-row-missing-then-delete-whole-group/m-p/511561#M2191</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2018-11-08T22:41:53Z</dc:date>
    </item>
  </channel>
</rss>

