<?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 Flag when between 2 dates with SQL in SAS Data Management</title>
    <link>https://communities.sas.com/t5/SAS-Data-Management/Flag-when-between-2-dates-with-SQL/m-p/515655#M16010</link>
    <description>&lt;P&gt;&lt;FONT face="times new roman,times" size="3"&gt;Hi all,&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="times new roman,times" size="3"&gt;May I know how do I flag my data entries when they are between 2 dates(disregard the time portion) using Sql? The datatype of the&amp;nbsp;condition_start_date column is timestamp with format YYYY-MM-DD HH:MM:SS&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="times new roman,times" size="3"&gt;Below is what I have tried.&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="times new roman,times" size="3"&gt;Your help is very much appreciated.&lt;/FONT&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;CREATE TABLE incl_crit1 AS
    SELECT *, CASE 
				WHEN condition_start_date BETWEEN "2010-07-01 00:00:00" and "2018-06-30 00:00:00" 
               		THEN 1 
               		ELSE 0 
       			END as incl_crit
    FROM cond_codes1)
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Fri, 23 Nov 2018 20:33:14 GMT</pubDate>
    <dc:creator>Miracle</dc:creator>
    <dc:date>2018-11-23T20:33:14Z</dc:date>
    <item>
      <title>Flag when between 2 dates with SQL</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Flag-when-between-2-dates-with-SQL/m-p/515655#M16010</link>
      <description>&lt;P&gt;&lt;FONT face="times new roman,times" size="3"&gt;Hi all,&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="times new roman,times" size="3"&gt;May I know how do I flag my data entries when they are between 2 dates(disregard the time portion) using Sql? The datatype of the&amp;nbsp;condition_start_date column is timestamp with format YYYY-MM-DD HH:MM:SS&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="times new roman,times" size="3"&gt;Below is what I have tried.&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="times new roman,times" size="3"&gt;Your help is very much appreciated.&lt;/FONT&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;CREATE TABLE incl_crit1 AS
    SELECT *, CASE 
				WHEN condition_start_date BETWEEN "2010-07-01 00:00:00" and "2018-06-30 00:00:00" 
               		THEN 1 
               		ELSE 0 
       			END as incl_crit
    FROM cond_codes1)
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 23 Nov 2018 20:33:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Flag-when-between-2-dates-with-SQL/m-p/515655#M16010</guid>
      <dc:creator>Miracle</dc:creator>
      <dc:date>2018-11-23T20:33:14Z</dc:date>
    </item>
    <item>
      <title>Re: Flag when between 2 dates with SQL</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Flag-when-between-2-dates-with-SQL/m-p/515659#M16012</link>
      <description>&lt;P&gt;SAS has only two data types, character and numeric. Which of those is condition_start_date?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Your condition would only work with character data.&lt;/P&gt;</description>
      <pubDate>Fri, 23 Nov 2018 20:38:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Flag-when-between-2-dates-with-SQL/m-p/515659#M16012</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-11-23T20:38:50Z</dc:date>
    </item>
    <item>
      <title>Re: Flag when between 2 dates with SQL</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Flag-when-between-2-dates-with-SQL/m-p/515662#M16013</link>
      <description>&lt;P&gt;Assuming that condition_start_date is in sas datetime format . You can use the Date constants in the between clause way :&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Proc SQl;
CREATE TABLE incl_crit1 AS
    SELECT *, CASE 
				WHEN condition_start_date BETWEEN '01jul2019 00:00:00'dt and '30jun2018 00:00:00'dt
               		THEN 1 
               		ELSE 0 
       			END as incl_crit
    FROM cond_codes1;
Quit;


&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 23 Nov 2018 21:03:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Flag-when-between-2-dates-with-SQL/m-p/515662#M16013</guid>
      <dc:creator>r_behata</dc:creator>
      <dc:date>2018-11-23T21:03:04Z</dc:date>
    </item>
    <item>
      <title>Re: Flag when between 2 dates with SQL</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Flag-when-between-2-dates-with-SQL/m-p/515664#M16014</link>
      <description>&lt;P&gt;If&amp;nbsp;&lt;EM&gt;condition_start_date&lt;/EM&gt; is a&amp;nbsp;SAS datetime (the format wouldn't matter), you could use:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;CREATE TABLE incl_crit1 AS
SELECT 
    *, 
    condition_start_date BETWEEN "01JUL2010:00:00:00"dt and "30JUN2018:23:59:59"dt as incl_crit
FROM cond_codes1;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If &lt;EM&gt;condition_start_date&lt;/EM&gt; is character then you could get away with:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;CREATE TABLE incl_crit1 AS
SELECT 
    *, 
    substr(condition_start_date,1,10) BETWEEN "2010-07-01" and "2018-06-30"  as incl_crit
FROM cond_codes1;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 23 Nov 2018 21:08:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Flag-when-between-2-dates-with-SQL/m-p/515664#M16014</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2018-11-23T21:08:22Z</dc:date>
    </item>
  </channel>
</rss>

