<?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 exclude all 'company_name' variable if one of the 'year' variable smaller than 2009. in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/exclude-all-company-name-variable-if-one-of-the-year-variable/m-p/536257#M147342</link>
    <description>&lt;P&gt;Dear all,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;how can I exclude all 'company_name' variable if one of the 'year' variable( belongs to the same 'company_name' group) smaller than 2009.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="sas"&gt;data old;&amp;lt;br /&amp;gt;input &amp;lt;br /&amp;gt;company_name $50. &amp;lt;br /&amp;gt;year 50.&amp;lt;br /&amp;gt;;&amp;lt;br /&amp;gt;datalines;
A, 1990&amp;lt;br /&amp;gt;A, 2011&amp;lt;br /&amp;gt;B, 2019
;
run;&amp;lt;code&amp;gt;&amp;lt;/code&amp;gt;&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;I expect to get&amp;nbsp;the result like&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;B, 2019&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;as one 'year' variable of company_name 'A' variable is 1990 (which is smaller than 2009), so, I exclude all A company,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;could you please&amp;nbsp;give me some suggestions about this?&lt;/P&gt;&lt;P&gt;thanks in advance&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sun, 17 Feb 2019 17:16:03 GMT</pubDate>
    <dc:creator>France</dc:creator>
    <dc:date>2019-02-17T17:16:03Z</dc:date>
    <item>
      <title>exclude all 'company_name' variable if one of the 'year' variable smaller than 2009.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/exclude-all-company-name-variable-if-one-of-the-year-variable/m-p/536257#M147342</link>
      <description>&lt;P&gt;Dear all,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;how can I exclude all 'company_name' variable if one of the 'year' variable( belongs to the same 'company_name' group) smaller than 2009.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="sas"&gt;data old;&amp;lt;br /&amp;gt;input &amp;lt;br /&amp;gt;company_name $50. &amp;lt;br /&amp;gt;year 50.&amp;lt;br /&amp;gt;;&amp;lt;br /&amp;gt;datalines;
A, 1990&amp;lt;br /&amp;gt;A, 2011&amp;lt;br /&amp;gt;B, 2019
;
run;&amp;lt;code&amp;gt;&amp;lt;/code&amp;gt;&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;I expect to get&amp;nbsp;the result like&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;B, 2019&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;as one 'year' variable of company_name 'A' variable is 1990 (which is smaller than 2009), so, I exclude all A company,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;could you please&amp;nbsp;give me some suggestions about this?&lt;/P&gt;&lt;P&gt;thanks in advance&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 17 Feb 2019 17:16:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/exclude-all-company-name-variable-if-one-of-the-year-variable/m-p/536257#M147342</guid>
      <dc:creator>France</dc:creator>
      <dc:date>2019-02-17T17:16:03Z</dc:date>
    </item>
    <item>
      <title>Re: exclude all 'company_name' variable if one of the 'year' variable smaller than 2009.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/exclude-all-company-name-variable-if-one-of-the-year-variable/m-p/536258#M147343</link>
      <description>&lt;P&gt;Do a subselect for the exclusion values, and use that in a where:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql ;
create table want as
select *
from old
where company_name not in (
  select company_name
  from old
  where min(year) &amp;lt; 2009
  group by company_name
);
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;(untested, posted from tablet)&lt;/P&gt;</description>
      <pubDate>Sun, 17 Feb 2019 17:53:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/exclude-all-company-name-variable-if-one-of-the-year-variable/m-p/536258#M147343</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2019-02-17T17:53:14Z</dc:date>
    </item>
    <item>
      <title>Re: exclude all 'company_name' variable if one of the 'year' variable smaller than 2009.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/exclude-all-company-name-variable-if-one-of-the-year-variable/m-p/536385#M147399</link>
      <description>&lt;P&gt;Since I'm now back in office, I could test it.&lt;/P&gt;
&lt;P&gt;First, it is always a &lt;STRONG&gt;VERY GOOD IDEA&lt;/STRONG&gt; to test your own datastep code for example data before posting it here. Testing is not a crime, it won't make you blind or cause your hair to fall out.&lt;/P&gt;
&lt;P&gt;Your code would not produce any data, instead it caused an ERROR message.&lt;/P&gt;
&lt;P&gt;I fixed it to this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data old;
infile datalines dlm=',';
input
  company_name $
  year
;
datalines;
A, 1990
A, 2011
B, 2019
;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;After that, I found my own code was using the summary function incorrectly, so I had to restructure the subselect to using a HAVING clause:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql ;
create table want as
select *
from old
where company_name not in (
  select company_name
  from old
  group by company_name
  having min(year) &amp;lt; 2009
);
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;This creates your expected result.&lt;/P&gt;</description>
      <pubDate>Mon, 18 Feb 2019 08:08:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/exclude-all-company-name-variable-if-one-of-the-year-variable/m-p/536385#M147399</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2019-02-18T08:08:21Z</dc:date>
    </item>
  </channel>
</rss>

