<?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 PROC SQL greater than not working in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/PROC-SQL-greater-than-not-working/m-p/824706#M325699</link>
    <description>&lt;P&gt;I have this code that works:&lt;/P&gt;
&lt;PRE&gt;proc sql;&lt;BR /&gt;create table DATA.DATA2 as&lt;BR /&gt;SELECT *&lt;BR /&gt;FROM data.DATA&lt;BR /&gt;WHERE START &amp;lt; '01JAN2018:00:00:00'dt&lt;BR /&gt;;&lt;BR /&gt;QUIT;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;Yet, I want greater than instead of lesser than. if I change it to greater than "&amp;gt;" or GT I get no output. I tried using&amp;nbsp;'01JAN2018'd instead and various other twerks, but I am lost.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Found this post that did not work:&amp;nbsp;&lt;A href="https://communities.sas.com/t5/SAS-Programming/PROC-SQL-condition-on-datetime-date/td-p/623110" target="_blank"&gt;https://communities.sas.com/t5/SAS-Programming/PROC-SQL-condition-on-datetime-date/td-p/623110&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;My START variable has date format DATE9. and length 8.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I hope someone can help.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Kind regards,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Jacob&lt;/P&gt;</description>
    <pubDate>Thu, 21 Jul 2022 15:49:19 GMT</pubDate>
    <dc:creator>jbrau123</dc:creator>
    <dc:date>2022-07-21T15:49:19Z</dc:date>
    <item>
      <title>PROC SQL greater than not working</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PROC-SQL-greater-than-not-working/m-p/824706#M325699</link>
      <description>&lt;P&gt;I have this code that works:&lt;/P&gt;
&lt;PRE&gt;proc sql;&lt;BR /&gt;create table DATA.DATA2 as&lt;BR /&gt;SELECT *&lt;BR /&gt;FROM data.DATA&lt;BR /&gt;WHERE START &amp;lt; '01JAN2018:00:00:00'dt&lt;BR /&gt;;&lt;BR /&gt;QUIT;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;Yet, I want greater than instead of lesser than. if I change it to greater than "&amp;gt;" or GT I get no output. I tried using&amp;nbsp;'01JAN2018'd instead and various other twerks, but I am lost.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Found this post that did not work:&amp;nbsp;&lt;A href="https://communities.sas.com/t5/SAS-Programming/PROC-SQL-condition-on-datetime-date/td-p/623110" target="_blank"&gt;https://communities.sas.com/t5/SAS-Programming/PROC-SQL-condition-on-datetime-date/td-p/623110&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;My START variable has date format DATE9. and length 8.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I hope someone can help.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Kind regards,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Jacob&lt;/P&gt;</description>
      <pubDate>Thu, 21 Jul 2022 15:49:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PROC-SQL-greater-than-not-working/m-p/824706#M325699</guid>
      <dc:creator>jbrau123</dc:creator>
      <dc:date>2022-07-21T15:49:19Z</dc:date>
    </item>
    <item>
      <title>Re: PROC SQL greater than not working</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PROC-SQL-greater-than-not-working/m-p/824709#M325702</link>
      <description>btw, I also tried this, which also did not work:&lt;BR /&gt;&lt;BR /&gt;data DATA.PERS3;&lt;BR /&gt;set DATA.PERS2;&lt;BR /&gt;where START &amp;gt; '01JAN2018:00:00:00'dt;&lt;BR /&gt;run;</description>
      <pubDate>Thu, 21 Jul 2022 16:00:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PROC-SQL-greater-than-not-working/m-p/824709#M325702</guid>
      <dc:creator>jbrau123</dc:creator>
      <dc:date>2022-07-21T16:00:45Z</dc:date>
    </item>
    <item>
      <title>Re: PROC SQL greater than not working</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PROC-SQL-greater-than-not-working/m-p/824711#M325703</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/228622"&gt;@jbrau123&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;I have this code that works:&lt;/P&gt;
&lt;PRE&gt;proc sql;&lt;BR /&gt;create table DATA.DATA2 as&lt;BR /&gt;SELECT *&lt;BR /&gt;FROM data.DATA&lt;BR /&gt;WHERE START &amp;lt; '01JAN2018:00:00:00'dt&lt;BR /&gt;;&lt;BR /&gt;QUIT;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;Yet, I want greater than instead of lesser than. if I change it to greater than "&amp;gt;" or GT I get no output. I tried using&amp;nbsp;'01JAN2018'd instead and various other twerks, but I am lost.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Found this post that did not work:&amp;nbsp;&lt;A href="https://communities.sas.com/t5/SAS-Programming/PROC-SQL-condition-on-datetime-date/td-p/623110" target="_blank" rel="noopener"&gt;https://communities.sas.com/t5/SAS-Programming/PROC-SQL-condition-on-datetime-date/td-p/623110&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#FF0000"&gt;&lt;STRONG&gt;My START variable has date format DATE9. and length 8.&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I hope someone can help.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Kind regards,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Jacob&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
create table DATA.DATA2 as
SELECT *
FROM data.DATA
WHERE START &amp;lt; '01JAN2018'd
;
QUIT;

proc sql;
create table DATA.DATA2 as
SELECT *
FROM data.DATA
WHERE START &amp;gt; '01JAN2018'd
;
QUIT;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If you have a date variable you need to be using a date comparison, you're currently using a datetime comparison. The first set of code may run, but I doubt it's correct if you examine the data. See the code above to compare to a date, not datetime.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here's a great, but longer and in depth, reference for dates and times in SAS&lt;BR /&gt;&lt;A href="https://communities.sas.com/t5/SAS-Communities-Library/Working-with-Dates-and-Times-in-SAS-Tutorial/ta-p/424354" target="_blank"&gt;https://communities.sas.com/t5/SAS-Communities-Library/Working-with-Dates-and-Times-in-SAS-Tutorial/ta-p/424354&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 21 Jul 2022 16:06:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PROC-SQL-greater-than-not-working/m-p/824711#M325703</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2022-07-21T16:06:20Z</dc:date>
    </item>
    <item>
      <title>Re: PROC SQL greater than not working</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PROC-SQL-greater-than-not-working/m-p/824712#M325704</link>
      <description>&lt;P&gt;Wonderful, thanks! I had quite a lot of trouble with that one&lt;/P&gt;</description>
      <pubDate>Thu, 21 Jul 2022 16:11:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PROC-SQL-greater-than-not-working/m-p/824712#M325704</guid>
      <dc:creator>jbrau123</dc:creator>
      <dc:date>2022-07-21T16:11:27Z</dc:date>
    </item>
    <item>
      <title>Re: PROC SQL greater than not working</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PROC-SQL-greater-than-not-working/m-p/824713#M325705</link>
      <description>&lt;P&gt;Dates in SAS use counts of DAYs. Datetime and Time values use counts of SECONDS. So if your START is a date you are comparing to a datetime value and the units are way different.&lt;/P&gt;
&lt;P&gt;Apply the DATEPART function to the datetime value for correct comparison with datetime values:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;proc sql;&lt;BR /&gt;create table DATA.DATA2 as&lt;BR /&gt;SELECT *&lt;BR /&gt;FROM data.DATA&lt;BR /&gt;WHERE START &amp;gt; datepart( '01JAN2018:00:00:00'dt)&lt;BR /&gt;;&lt;BR /&gt;QUIT;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;OR provide the date directly instead of a datetime.&lt;/P&gt;
&lt;PRE&gt;proc sql;&lt;BR /&gt;create table DATA.DATA2 as&lt;BR /&gt;SELECT *&lt;BR /&gt;FROM data.DATA&lt;BR /&gt;WHERE START &amp;gt; '01JAN2018'd&lt;BR /&gt;;&lt;BR /&gt;QUIT;&amp;nbsp;&amp;nbsp;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 21 Jul 2022 16:14:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PROC-SQL-greater-than-not-working/m-p/824713#M325705</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2022-07-21T16:14:16Z</dc:date>
    </item>
  </channel>
</rss>

