<?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 Struggling with date variables in SAS Data Management</title>
    <link>https://communities.sas.com/t5/SAS-Data-Management/Struggling-with-date-variables/m-p/112098#M1301</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;In DI Studio, I have an extract transformation that needs to extract all rows where &lt;STRONG&gt;&amp;amp;extract_dttm&lt;/STRONG&gt; is between &lt;STRONG&gt;valid_from_dttm&lt;/STRONG&gt; and &lt;STRONG&gt;valid_to_dttm&lt;/STRONG&gt;. So, I've set up this basic where-statement to start with:&lt;STRONG&gt;&lt;BR /&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;STRONG&gt;&amp;amp;extract_dttm BETWEEN valid_from_dttm AND valid_to_dttm;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;valid_from_dttm&lt;/STRONG&gt; and &lt;STRONG&gt;valid_to_dttm&lt;/STRONG&gt; are numeric variables with the format NLDATM21.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;amp;extract_dttm &lt;/STRONG&gt;is set up by means of this precode:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;STRONG&gt;%let extract_dttm = %sysfunc(putn(%sysfunc(intnx(DTMONTH, %sysfunc(DATETIME()), -1, E)), NLDATM21.));&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;When using &lt;STRONG&gt;%put &amp;amp;extract_dttm;&lt;/STRONG&gt; it appears like this in the log:&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;30.sep.12 23:59:59&amp;nbsp;&amp;nbsp;&amp;nbsp; (which looks just like &lt;STRONG&gt;valid_from_dttm&lt;/STRONG&gt; and &lt;STRONG&gt;valid_to_dttm&lt;/STRONG&gt; in the input table)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Apparently &lt;STRONG&gt;&amp;amp;extract_dttm&lt;/STRONG&gt; can't be compared to the numeric &lt;STRONG&gt;valid_from_dttm&lt;/STRONG&gt; and &lt;STRONG&gt;valid_to_dttm &lt;/STRONG&gt;because it's a character. How can I edit the precode or where-statement to successfully extract the correct rows?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'd greatly appreciate any insight, as I've been struggling with variations of this code for days now. I'm very inexperienced in using date and macro variables.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks for your time. &lt;img id="smileyhappy" class="emoticon emoticon-smileyhappy" src="https://communities.sas.com/i/smilies/16x16_smiley-happy.png" alt="Smiley Happy" title="Smiley Happy" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 30 Oct 2012 20:16:46 GMT</pubDate>
    <dc:creator>EinarRoed</dc:creator>
    <dc:date>2012-10-30T20:16:46Z</dc:date>
    <item>
      <title>Struggling with date variables</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Struggling-with-date-variables/m-p/112098#M1301</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;In DI Studio, I have an extract transformation that needs to extract all rows where &lt;STRONG&gt;&amp;amp;extract_dttm&lt;/STRONG&gt; is between &lt;STRONG&gt;valid_from_dttm&lt;/STRONG&gt; and &lt;STRONG&gt;valid_to_dttm&lt;/STRONG&gt;. So, I've set up this basic where-statement to start with:&lt;STRONG&gt;&lt;BR /&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;STRONG&gt;&amp;amp;extract_dttm BETWEEN valid_from_dttm AND valid_to_dttm;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;valid_from_dttm&lt;/STRONG&gt; and &lt;STRONG&gt;valid_to_dttm&lt;/STRONG&gt; are numeric variables with the format NLDATM21.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;amp;extract_dttm &lt;/STRONG&gt;is set up by means of this precode:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;STRONG&gt;%let extract_dttm = %sysfunc(putn(%sysfunc(intnx(DTMONTH, %sysfunc(DATETIME()), -1, E)), NLDATM21.));&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;When using &lt;STRONG&gt;%put &amp;amp;extract_dttm;&lt;/STRONG&gt; it appears like this in the log:&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;30.sep.12 23:59:59&amp;nbsp;&amp;nbsp;&amp;nbsp; (which looks just like &lt;STRONG&gt;valid_from_dttm&lt;/STRONG&gt; and &lt;STRONG&gt;valid_to_dttm&lt;/STRONG&gt; in the input table)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Apparently &lt;STRONG&gt;&amp;amp;extract_dttm&lt;/STRONG&gt; can't be compared to the numeric &lt;STRONG&gt;valid_from_dttm&lt;/STRONG&gt; and &lt;STRONG&gt;valid_to_dttm &lt;/STRONG&gt;because it's a character. How can I edit the precode or where-statement to successfully extract the correct rows?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'd greatly appreciate any insight, as I've been struggling with variations of this code for days now. I'm very inexperienced in using date and macro variables.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks for your time. &lt;img id="smileyhappy" class="emoticon emoticon-smileyhappy" src="https://communities.sas.com/i/smilies/16x16_smiley-happy.png" alt="Smiley Happy" title="Smiley Happy" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 30 Oct 2012 20:16:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Struggling-with-date-variables/m-p/112098#M1301</guid>
      <dc:creator>EinarRoed</dc:creator>
      <dc:date>2012-10-30T20:16:46Z</dc:date>
    </item>
    <item>
      <title>Re: Struggling with date variables</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Struggling-with-date-variables/m-p/112099#M1302</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;All macro variables are characters.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;To use them as date or date time values you can enclose them in quotations with the appropriate letters afterwards.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;IE.&lt;/P&gt;&lt;P&gt;Date:&lt;/P&gt;&lt;P&gt;"01Apr2011"d&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Date Time&lt;/P&gt;&lt;P&gt;"25dec2000:15:01"dt&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 30 Oct 2012 20:29:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Struggling-with-date-variables/m-p/112099#M1302</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2012-10-30T20:29:27Z</dc:date>
    </item>
  </channel>
</rss>

