<?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 SAS date filters in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/SAS-date-filters/m-p/653945#M196438</link>
    <description>&lt;P&gt;Hi SAS users,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I need help with date filters. I created test1 and using those paid dates for test2 dataset where conditions.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc sql;&lt;BR /&gt;create table test1 as&lt;BR /&gt;select service_date ,&lt;BR /&gt;datepart(service_date) FORMAT YYMMDDD10. as fdos,&lt;BR /&gt;datepart(paid_date) FORMAT YYMMDDD10. as paid&lt;BR /&gt;from &lt;BR /&gt;test;&lt;BR /&gt;Quit;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc sql;&lt;BR /&gt;create table test2 as&lt;BR /&gt;select&lt;BR /&gt;*&lt;BR /&gt;from test1&lt;BR /&gt;where &lt;STRONG&gt;paid between '2019-05-01' and '2020-04-30'&amp;nbsp; &amp;nbsp; ( need help here how to get paid into character format )&lt;/STRONG&gt;&lt;BR /&gt;;&lt;BR /&gt;Quit;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks,&lt;/P&gt;
&lt;P&gt;Ana&lt;/P&gt;</description>
    <pubDate>Sat, 06 Jun 2020 21:43:44 GMT</pubDate>
    <dc:creator>SASAna</dc:creator>
    <dc:date>2020-06-06T21:43:44Z</dc:date>
    <item>
      <title>SAS date filters</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-date-filters/m-p/653945#M196438</link>
      <description>&lt;P&gt;Hi SAS users,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I need help with date filters. I created test1 and using those paid dates for test2 dataset where conditions.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc sql;&lt;BR /&gt;create table test1 as&lt;BR /&gt;select service_date ,&lt;BR /&gt;datepart(service_date) FORMAT YYMMDDD10. as fdos,&lt;BR /&gt;datepart(paid_date) FORMAT YYMMDDD10. as paid&lt;BR /&gt;from &lt;BR /&gt;test;&lt;BR /&gt;Quit;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc sql;&lt;BR /&gt;create table test2 as&lt;BR /&gt;select&lt;BR /&gt;*&lt;BR /&gt;from test1&lt;BR /&gt;where &lt;STRONG&gt;paid between '2019-05-01' and '2020-04-30'&amp;nbsp; &amp;nbsp; ( need help here how to get paid into character format )&lt;/STRONG&gt;&lt;BR /&gt;;&lt;BR /&gt;Quit;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks,&lt;/P&gt;
&lt;P&gt;Ana&lt;/P&gt;</description>
      <pubDate>Sat, 06 Jun 2020 21:43:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-date-filters/m-p/653945#M196438</guid>
      <dc:creator>SASAna</dc:creator>
      <dc:date>2020-06-06T21:43:44Z</dc:date>
    </item>
    <item>
      <title>Re: SAS date filters</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-date-filters/m-p/653947#M196439</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/86567"&gt;@SASAna&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hi SAS users,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I need help with date filters. I created test1 and using those paid dates for test2 dataset where conditions.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc sql;&lt;BR /&gt;create table test1 as&lt;BR /&gt;select service_date ,&lt;BR /&gt;datepart(service_date) FORMAT YYMMDDD10. as fdos,&lt;BR /&gt;datepart(paid_date) FORMAT YYMMDDD10. as paid&lt;BR /&gt;from &lt;BR /&gt;test;&lt;BR /&gt;Quit;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc sql;&lt;BR /&gt;create table test2 as&lt;BR /&gt;select&lt;BR /&gt;*&lt;BR /&gt;from test1&lt;BR /&gt;where &lt;STRONG&gt;paid between '2019-05-01' and '2020-04-30'&amp;nbsp; &amp;nbsp; ( need help here how to get paid into character format )&lt;/STRONG&gt;&lt;BR /&gt;;&lt;BR /&gt;Quit;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;I believe you simply need to change the WHERE clause&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;where paid between '01MAY2019'd and '30APR2020'd&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Formats applied to the variable PAID are irrelevant here — if you have a numeric date variable (which PAID is), they can be formatted with any date format you want, it is completely irrelevant to the WHERE clause because when SAS does the comparisons, it uses the unformatted date number. To determine if it is between two dates that you want to hard code, then you must use the formatting of '01MAY2019'd and no other formatting (except that the letters can be either upper or lower case, and you can usually get away with using 2 digit years).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can combine your two PROC SQL blocks into a single call to PROC SQL&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
create table test1 as
select service_date ,
datepart(service_date) FORMAT YYMMDDD10. as fdos,
datepart(paid_date) FORMAT YYMMDDD10. as paid
from test 
where datepart(paid_date) between '01MAY2019'd and '30APR2020'd;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 08 Jun 2020 11:08:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-date-filters/m-p/653947#M196439</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2020-06-08T11:08:07Z</dc:date>
    </item>
  </channel>
</rss>

