<?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: Making a precode macro variable work properly for use in a where-statement in SAS Data Management</title>
    <link>https://communities.sas.com/t5/SAS-Data-Management/Making-a-precode-macro-variable-work-properly-for-use-in-a-where/m-p/106401#M1192</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;One of the rows in the input table has these values:&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;VALID_FROM_DTTM&lt;/SPAN&gt;: 02OCT12:12:31:02&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;VALID_TO_DTTM&lt;/SPAN&gt;: 01JAN99:00:00:00&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;Using &lt;SPAN style="font-size: 12px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;STRONG&gt;&lt;A _jive_internal="true" class="jiveTT-hover-user jive-username-link" data-avatarid="-1" data-externalid="" data-presence="null" data-userid="809684" data-username="RichardinOz" href="https://communities.sas.com/people/RichardinOz" id="jive-80968451649356745752803" style="padding: 0 3px 0 0; font-weight: inherit; font-style: inherit; font-size: 1.1em; font-family: inherit; color: #0e66ba;"&gt;RichardinOz's &lt;/A&gt;&lt;/STRONG&gt;&lt;/SPAN&gt;helpful suggestion, the log confirms that &amp;amp;extract_dttm has this value: 31OCT12:23:59:59.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;Yet, the following where-statement in the Extract doesn't extract any values:&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&amp;amp;extract_dttm BETWEEN VALID_FROM_DTTM AND VALID_TO_DTTM&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;This is the precode I'm using (which generates the correct value &lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;31OCT12:23:59:59&lt;/SPAN&gt;&lt;span class="lia-unicode-emoji" title=":disappointed_face:"&gt;😞&lt;/span&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;%let extract_dttm = %Sysfunc(putn(%sysfunc(intnx(DTMONTH, %sysfunc(DATETIME()), &amp;amp;back., E)), datetime.));&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;How can I modify the where-statement or precode to resolve this, so that the Extract works as intended? I've tried using ""dt on the variables in numerous combinations, but perhaps I've missed one.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;UPDATE: Sorry, resolved, thanks again Richard. &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;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 25 Oct 2012 10:53:45 GMT</pubDate>
    <dc:creator>TurnTheBacon</dc:creator>
    <dc:date>2012-10-25T10:53:45Z</dc:date>
    <item>
      <title>Making a precode macro variable work properly for use in a where-statement</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Making-a-precode-macro-variable-work-properly-for-use-in-a-where/m-p/106396#M1187</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I'm using the following precode in an Extract transformation:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD style="padding-left: 30px;"&gt;%let extract_dttm = intnx('DTMONTH',DATETIME(),&amp;amp;back.,'E');&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P style="padding-left: 30px;"&gt;%put &amp;amp;extract_dttm;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The purpose of the Extract, if run today, is to extract all rows with extract_dttm between Valid_From_DTTM and Valid_From_DTTM&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The &amp;amp;back parameter is -1, to designate the previous month.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;When I run the Extract, %put &amp;amp;extract_dttm prints the text "intnx('DTMONTH',DATETIME(),-1,'E')" to the log. How do I turn this into a value? I need to be able to use it in this WHERE-statement:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&amp;amp;extract_dttm. BETWEEN Valid_From_DTTM AND Valid_From_DTTM&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>Thu, 25 Oct 2012 08:44:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Making-a-precode-macro-variable-work-properly-for-use-in-a-where/m-p/106396#M1187</guid>
      <dc:creator>TurnTheBacon</dc:creator>
      <dc:date>2012-10-25T08:44:31Z</dc:date>
    </item>
    <item>
      <title>Re: Making a precode macro variable work properly for use in a where-statement</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Making-a-precode-macro-variable-work-properly-for-use-in-a-where/m-p/106397#M1188</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You have a mix of Base and Macro:&amp;nbsp; the macro compiler will treat intnx as text.&lt;/P&gt;&lt;P&gt;Use %sysfunc to bring intnx into the macro compiler.&amp;nbsp; May also need %sysevalf&lt;/P&gt;&lt;P&gt;Try this&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; %let extract_dttm = %sysevalf(%sysfunc(intnx(DTMONTH,%sysfunc(DATETIME()),&amp;amp;back.,E))) ;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; %put &amp;amp;extract_dttm;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;Regards&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;Richard in Oz&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 25 Oct 2012 08:55:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Making-a-precode-macro-variable-work-properly-for-use-in-a-where/m-p/106397#M1188</guid>
      <dc:creator>RichardinOz</dc:creator>
      <dc:date>2012-10-25T08:55:05Z</dc:date>
    </item>
    <item>
      <title>Re: Making a precode macro variable work properly for use in a where-statement</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Making-a-precode-macro-variable-work-properly-for-use-in-a-where/m-p/106398#M1189</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If you want to check the date, &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; %Put %Sysfunc(putn(&amp;amp;extract_dttm, datetime.)) ;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;30SEP12:23:59:59&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 25 Oct 2012 09:02:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Making-a-precode-macro-variable-work-properly-for-use-in-a-where/m-p/106398#M1189</guid>
      <dc:creator>RichardinOz</dc:creator>
      <dc:date>2012-10-25T09:02:04Z</dc:date>
    </item>
    <item>
      <title>Re: Making a precode macro variable work properly for use in a where-statement</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Making-a-precode-macro-variable-work-properly-for-use-in-a-where/m-p/106399#M1190</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Here is the all-singing, all-dancing version&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%macro Datelimit (back) ;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; %local set_dttm ;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; %Let set_dttm = %sysevalf(%sysfunc(intnx(DTMONTH,%sysfunc(DATETIME()),&amp;amp;back.,E))) ;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; %* no semiclolon on next line ;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; %Unquote(%Str(%')%sysfunc(Putn(&amp;amp;set_dttm, datetime20.))%str(%')DT)&lt;/P&gt;&lt;P&gt;%Mend ;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%Put Where extract_dttm Between %Datelimit(-3) and %Datelimit(-1) ;&lt;/P&gt;&lt;P&gt;Where extract_dttm Between '&amp;nbsp; 31JUL2012:23:59:59'DT and '&amp;nbsp; 30SEP2012:23:59:59'DT&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Enjoy&lt;/P&gt;&lt;P&gt;Richard in Oz&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 25 Oct 2012 09:14:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Making-a-precode-macro-variable-work-properly-for-use-in-a-where/m-p/106399#M1190</guid>
      <dc:creator>RichardinOz</dc:creator>
      <dc:date>2012-10-25T09:14:49Z</dc:date>
    </item>
    <item>
      <title>Re: Making a precode macro variable work properly for use in a where-statement</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Making-a-precode-macro-variable-work-properly-for-use-in-a-where/m-p/106400#M1191</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks, turns out I didn't need the %&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;sysevalf for it to run. The log now shows me the value 1667347199 for &amp;amp;extract_dttm. However, I'm still unclear on how I can make the Extract work as intended, to extract all values where &amp;amp;extract_dttm is between Valid_From_DTTM and Valid_To_DTTM.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The where-statement says: &lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&amp;amp;extract_dttm. BETWEEN Valid_From_DTTM AND Valid_From_DTTM.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;amp;extract_dttm currently has the value 1667347199, while Valid_From_DTTM and Valid_To-DTTM have the NLDATM21-format, appearing as for example 02SEP12:12:31:02.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;What can I do in the where-statement to turn Valid_From_DTTM and Valid_From_DTTM into the same kind of format as &amp;amp;extract_dttm? I assume that's the way to go.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Sorry for the newbie'ish question. &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>Thu, 25 Oct 2012 09:25:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Making-a-precode-macro-variable-work-properly-for-use-in-a-where/m-p/106400#M1191</guid>
      <dc:creator>TurnTheBacon</dc:creator>
      <dc:date>2012-10-25T09:25:55Z</dc:date>
    </item>
    <item>
      <title>Re: Making a precode macro variable work properly for use in a where-statement</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Making-a-precode-macro-variable-work-properly-for-use-in-a-where/m-p/106401#M1192</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;One of the rows in the input table has these values:&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;VALID_FROM_DTTM&lt;/SPAN&gt;: 02OCT12:12:31:02&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;VALID_TO_DTTM&lt;/SPAN&gt;: 01JAN99:00:00:00&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;Using &lt;SPAN style="font-size: 12px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;STRONG&gt;&lt;A _jive_internal="true" class="jiveTT-hover-user jive-username-link" data-avatarid="-1" data-externalid="" data-presence="null" data-userid="809684" data-username="RichardinOz" href="https://communities.sas.com/people/RichardinOz" id="jive-80968451649356745752803" style="padding: 0 3px 0 0; font-weight: inherit; font-style: inherit; font-size: 1.1em; font-family: inherit; color: #0e66ba;"&gt;RichardinOz's &lt;/A&gt;&lt;/STRONG&gt;&lt;/SPAN&gt;helpful suggestion, the log confirms that &amp;amp;extract_dttm has this value: 31OCT12:23:59:59.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;Yet, the following where-statement in the Extract doesn't extract any values:&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&amp;amp;extract_dttm BETWEEN VALID_FROM_DTTM AND VALID_TO_DTTM&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;This is the precode I'm using (which generates the correct value &lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;31OCT12:23:59:59&lt;/SPAN&gt;&lt;span class="lia-unicode-emoji" title=":disappointed_face:"&gt;😞&lt;/span&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;%let extract_dttm = %Sysfunc(putn(%sysfunc(intnx(DTMONTH, %sysfunc(DATETIME()), &amp;amp;back., E)), datetime.));&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;How can I modify the where-statement or precode to resolve this, so that the Extract works as intended? I've tried using ""dt on the variables in numerous combinations, but perhaps I've missed one.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;UPDATE: Sorry, resolved, thanks again Richard. &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;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 25 Oct 2012 10:53:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Making-a-precode-macro-variable-work-properly-for-use-in-a-where/m-p/106401#M1192</guid>
      <dc:creator>TurnTheBacon</dc:creator>
      <dc:date>2012-10-25T10:53:45Z</dc:date>
    </item>
    <item>
      <title>Re: Making a precode macro variable work properly for use in a where-statement</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Making-a-precode-macro-variable-work-properly-for-use-in-a-where/m-p/106402#M1193</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;SPAN style="font-family: arial, helvetica, sans-serif; background-color: #ffffff;"&gt;You need to use four digit years in your datetime literals.&amp;nbsp; Depending on the setting of the yearcutoff option '99' could be interpreted as '1999' or '2099'.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: arial, helvetica, sans-serif; background-color: #ffffff;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;data test ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt; input (fromdt todt) (:datetime20.);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt; format fromdt todt datetime20. ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt; put (_all_) (=);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;cards;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;02OCT12:12:31:02 01JAN99:00:00:00&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;02OCT2012:12:31:02 01JAN2099:00:00:00&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;run;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier; background-color: #ffffff;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;fromdt=02OCT2012:12:31:02 todt=01JAN1999:00:00:00&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;fromdt=02OCT2012:12:31:02 todt=01JAN2099:00:00:00&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Datetime variables in SAS are numbers that store the number of seconds since 01JAN1960. So the time 31OCT2012:23:59:59 will be stored as the number 1667347199.&amp;nbsp; You can specify a specific datetime value by that number or you can use a datetime literal to make it easier for humans to read.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you have a macro variable with the value 31OCT2012:23:59:59 and you want to use it in a WHERE statement to compare it to values in a datetime variable then just use the datetime literal format.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier; background-color: #ffffff;"&gt;&lt;STRONG&gt;WHERE&lt;/STRONG&gt; "&amp;amp;extract_dttm"dt &lt;STRONG&gt;BETWEEN&lt;/STRONG&gt; VALID_FROM_DTTM &lt;STRONG&gt;AND&lt;/STRONG&gt; VALID_TO_DTTM&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier; background-color: #ffffff;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier; background-color: #ffffff;"&gt;Now if your dataset variables are character strings instead of actual datetime values then you need to convert those to numbers to get the comparison to work.&amp;nbsp; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier; background-color: #ffffff;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-family: 'courier new', courier;"&gt;WHERE&lt;/STRONG&gt;&lt;SPAN style="font-family: 'courier new', courier; background-color: #ffffff;"&gt; "&amp;amp;extract_dttm"dt &lt;/SPAN&gt;&lt;STRONG style="font-family: 'courier new', courier;"&gt;BETWEEN&lt;/STRONG&gt;&lt;SPAN style="font-family: 'courier new', courier; background-color: #ffffff;"&gt; input(VALID_FROM_DTTM,datetime.) &lt;/SPAN&gt;&lt;STRONG style="font-family: 'courier new', courier;"&gt;AND&lt;/STRONG&gt;&lt;SPAN style="font-family: 'courier new', courier; background-color: #ffffff;"&gt; input(VALID_TO_DTTM,datetime.)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier; background-color: #ffffff;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier; background-color: #ffffff;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 25 Oct 2012 11:56:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Making-a-precode-macro-variable-work-properly-for-use-in-a-where/m-p/106402#M1193</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2012-10-25T11:56:37Z</dc:date>
    </item>
  </channel>
</rss>

