<?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: proc sql select distinct except in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/proc-sql-select-distinct-except/m-p/750740#M236192</link>
    <description>&lt;P&gt;Yes, you can stack set operators. They would go before the quit statement like you said. You should look at the table that is created to verify you got the desired output.&lt;/P&gt;</description>
    <pubDate>Mon, 28 Jun 2021 01:37:29 GMT</pubDate>
    <dc:creator>tarheel13</dc:creator>
    <dc:date>2021-06-28T01:37:29Z</dc:date>
    <item>
      <title>proc sql select distinct except</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-sql-select-distinct-except/m-p/750729#M236186</link>
      <description>&lt;P&gt;I have the following code to find cities that are in records for May, which are not present in April. If I want to check 'City' values in May that are not present also in February and March, would the correct thing to do be to add on the following before the the quit statement at the end, or is the code to add on different?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;CODE class=" language-sas"&gt;except
        select distinct City
                from Test
                where "01Mar2021"d&amp;lt;=MONTH&amp;lt;="31Mar2021"d&lt;/CODE&gt;&lt;/P&gt;
&lt;P&gt;&lt;CODE class=" language-sas"&gt;except
        select distinct City
                from Test
                where "01Feb2021"d&amp;lt;=MONTH&amp;lt;="28Feb2021"d&lt;/CODE&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
        select distinct City
                from Test
                where "01May2021"d&amp;lt;=MONTH&amp;lt;="31May2021"d
        except
        select distinct City
                from Test
                where "01Apr2021"d&amp;lt;=MONTH&amp;lt;="30Apr2021"d
       ;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 27 Jun 2021 23:23:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-sql-select-distinct-except/m-p/750729#M236186</guid>
      <dc:creator>Justin9</dc:creator>
      <dc:date>2021-06-27T23:23:27Z</dc:date>
    </item>
    <item>
      <title>Re: proc sql select distinct except</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-sql-select-distinct-except/m-p/750740#M236192</link>
      <description>&lt;P&gt;Yes, you can stack set operators. They would go before the quit statement like you said. You should look at the table that is created to verify you got the desired output.&lt;/P&gt;</description>
      <pubDate>Mon, 28 Jun 2021 01:37:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-sql-select-distinct-except/m-p/750740#M236192</guid>
      <dc:creator>tarheel13</dc:creator>
      <dc:date>2021-06-28T01:37:29Z</dc:date>
    </item>
    <item>
      <title>Re: proc sql select distinct except</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-sql-select-distinct-except/m-p/750744#M236195</link>
      <description>&lt;P&gt;If the purpose is to get City present in May of 2021 when not present between 01Feb2021 and 30Apr2021 it would be more efficient to use a wider range like&lt;/P&gt;
&lt;LI-CODE lang="sas"&gt;proc sql;
        select distinct City
                from Test
                where "01May2021"d&amp;lt;=MONTH&amp;lt;="31May2021"d
        except
        select distinct City
                from Test
                where "01FEB2021"d&amp;lt;=MONTH&amp;lt;="30Apr2021"d
       ;
quit;&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you want separate sets of first appearing in a given month I would probably use a different approach involving finding the Minimum (earliest) date that each city appears in the data.&lt;/P&gt;
&lt;P&gt;The multiple Excepts would cause more memory overhead and just plain more complicated coding.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 28 Jun 2021 02:45:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-sql-select-distinct-except/m-p/750744#M236195</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2021-06-28T02:45:52Z</dc:date>
    </item>
  </channel>
</rss>

