<?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: How do I pass a date macro variable as a parameter in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-pass-a-date-macro-variable-as-a-parameter/m-p/427043#M281353</link>
    <description>&lt;P&gt;Ok...let's say I don't want to run your code, can you please explain what issue you're having.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Off the bat, it looks like you may be using macro variables with single quotes, which won't work.&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;and LEVEL_CD='&amp;amp;V3'&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;What formats/ types are your data in the data base. And does your code work before you turned it into a macro? If so, what did that look like?&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;You also used double == in your macro call which could be incorrect, not sure how it would be interpreted.&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Thu, 11 Jan 2018 22:23:36 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2018-01-11T22:23:36Z</dc:date>
    <item>
      <title>How do I pass a date macro variable as a parameter</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-pass-a-date-macro-variable-as-a-parameter/m-p/427042#M281352</link>
      <description>&lt;P&gt;I am trying to pass a date macro variable into another macro variable and unable to do that.&amp;nbsp; Here is the code that I am using&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;LET TODAY = %sysfunc(TODAY(),DATE9.);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;data&lt;/STRONG&gt; dates;&lt;/P&gt;&lt;P&gt;lastwk=intnx('week', &lt;STRONG&gt;"&amp;amp;TODAY."D&lt;/STRONG&gt;, -&lt;STRONG&gt;2&lt;/STRONG&gt;);&lt;/P&gt;&lt;P&gt;last7wk=intnx('week', &lt;STRONG&gt;"&amp;amp;TODAY."D&lt;/STRONG&gt;, -&lt;STRONG&gt;8&lt;/STRONG&gt;);&lt;/P&gt;&lt;P&gt;lastSun= intnx('week.1', lastwk , &lt;STRONG&gt;1&lt;/STRONG&gt;);&lt;/P&gt;&lt;P&gt;last7Sun= intnx('week.1', last7wk , &lt;STRONG&gt;1&lt;/STRONG&gt;);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;format lastwk date9.;&lt;/P&gt;&lt;P&gt;format last7wk date9.;&lt;/P&gt;&lt;P&gt;format last7Sun date9.;&lt;/P&gt;&lt;P&gt;format lastSun date9.;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;call symput('lastwk',lastwk);&lt;/P&gt;&lt;P&gt;call symput('lastwk_Sun',lastwk);&lt;/P&gt;&lt;P&gt;call symput('last7Sun',last7Sun);&lt;/P&gt;&lt;P&gt;call symput('lastSun',lastSun);&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;%macro&lt;/STRONG&gt; test(V1=,V2=,V3=);&amp;nbsp;&lt;/P&gt;&lt;P&gt;select *&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; , case&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; when No in (&lt;STRONG&gt;1648&lt;/STRONG&gt;,&lt;STRONG&gt;1653&lt;/STRONG&gt;,&lt;STRONG&gt;1612&lt;/STRONG&gt;, &lt;STRONG&gt;1650&lt;/STRONG&gt;)then 'Express'&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; when No in &amp;nbsp;(&lt;STRONG&gt;1638&lt;/STRONG&gt;,&lt;STRONG&gt;1634&lt;/STRONG&gt;,&lt;STRONG&gt;1637&lt;/STRONG&gt;,&lt;STRONG&gt;1661&lt;/STRONG&gt;) then 'Non-Express'&lt;/P&gt;&lt;P&gt;else 'none' End as Mode&lt;/P&gt;&lt;P&gt;from (&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; SELECT *&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; FROM XXXX.ABCD t1&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; WHERE t1.ACTION_DATE&amp;gt;=&amp;amp;V1. and&amp;nbsp; t1.ACTION_DATE&amp;lt; &amp;amp;V2. and&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; t1.No in (&lt;STRONG&gt;1648&lt;/STRONG&gt;,&lt;STRONG&gt;1653&lt;/STRONG&gt;,&lt;STRONG&gt;1612&lt;/STRONG&gt;, &lt;STRONG&gt;1650, 1638&lt;/STRONG&gt;,&lt;STRONG&gt;1634&lt;/STRONG&gt;,&lt;STRONG&gt;1637&lt;/STRONG&gt;,&lt;STRONG&gt;1661,1974&lt;/STRONG&gt;,&lt;STRONG&gt;1975&lt;/STRONG&gt;,&lt;STRONG&gt;1976&lt;/STRONG&gt;)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; and LEVEL_CD='&amp;amp;V3'&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;) T1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;%mend&lt;/STRONG&gt;;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;proc&lt;/STRONG&gt; &lt;STRONG&gt;sql&lt;/STRONG&gt;;&lt;/P&gt;&lt;P&gt;create table table_2 as&amp;nbsp;&lt;/P&gt;&lt;P&gt;select *&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; From&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; (%&lt;STRONG&gt;&lt;EM&gt;test&lt;/EM&gt;&lt;/STRONG&gt;(V1=&amp;amp;last7Sun.,V2==&amp;amp;lastSun.,V3=&lt;STRONG&gt;2&lt;/STRONG&gt;) )T2&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Quit&lt;/STRONG&gt;;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks in Advance.&lt;/P&gt;</description>
      <pubDate>Thu, 11 Jan 2018 22:18:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-pass-a-date-macro-variable-as-a-parameter/m-p/427042#M281352</guid>
      <dc:creator>jb9977</dc:creator>
      <dc:date>2018-01-11T22:18:15Z</dc:date>
    </item>
    <item>
      <title>Re: How do I pass a date macro variable as a parameter</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-pass-a-date-macro-variable-as-a-parameter/m-p/427043#M281353</link>
      <description>&lt;P&gt;Ok...let's say I don't want to run your code, can you please explain what issue you're having.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Off the bat, it looks like you may be using macro variables with single quotes, which won't work.&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;and LEVEL_CD='&amp;amp;V3'&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;What formats/ types are your data in the data base. And does your code work before you turned it into a macro? If so, what did that look like?&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;You also used double == in your macro call which could be incorrect, not sure how it would be interpreted.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 11 Jan 2018 22:23:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-pass-a-date-macro-variable-as-a-parameter/m-p/427043#M281353</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-01-11T22:23:36Z</dc:date>
    </item>
    <item>
      <title>Re: How do I pass a date macro variable as a parameter</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-pass-a-date-macro-variable-as-a-parameter/m-p/427045#M281354</link>
      <description>What does "unable to" mean?  &lt;BR /&gt;&lt;BR /&gt;In general, if you're staying within SAS-land, I would not format it nicely; so remove the `,DATE9.` from your %SYSFUNC.  Leave it as the bare return value (a number).  Then you don't have to do the "&amp;amp;DATE"d stuff, you can just treat it as any other number, unless you actually need to print it nicely in which case you always can use %SYSFUNC(PUTN(...)) to get it printed nicely.&lt;BR /&gt;&lt;BR /&gt;If your XXXX library is in some other DBMS, though, like Oracle or SQL Server, you may have some issues filtering; you should specify in more detail in your question.</description>
      <pubDate>Thu, 11 Jan 2018 22:23:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-pass-a-date-macro-variable-as-a-parameter/m-p/427045#M281354</guid>
      <dc:creator>snoopy369</dc:creator>
      <dc:date>2018-01-11T22:23:54Z</dc:date>
    </item>
    <item>
      <title>Re: How do I pass a date macro variable as a parameter</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-pass-a-date-macro-variable-as-a-parameter/m-p/427068#M281355</link>
      <description>&lt;P&gt;Why&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#ff0000" size="4"&gt;&lt;STRONG&gt;%LET TODAY = %sysfunc(TODAY(),DATE9.);&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#ff0000" size="4"&gt;&lt;STRONG&gt;&amp;nbsp;&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#ff0000" size="4"&gt;&lt;STRONG&gt;data dates;&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#ff0000" size="4"&gt;&lt;STRONG&gt;lastwk=intnx('week', "&amp;amp;TODAY."D, -2);&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#ff0000" size="4"&gt;&lt;STRONG&gt;last7wk=intnx('week', "&amp;amp;TODAY."D, -8);&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000000" size="3"&gt;Your %let statement calls the &lt;STRONG&gt;datastep function today()&lt;/STRONG&gt;. Since you are running a data step why not run it in the data step?????&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;data&lt;/STRONG&gt; dates;&lt;/P&gt;
&lt;P&gt;lastwk=intnx('week', &lt;STRONG&gt;today()&lt;/STRONG&gt;, -&lt;STRONG&gt;2&lt;/STRONG&gt;);&lt;/P&gt;
&lt;P&gt;last7wk=intnx('week', &lt;STRONG&gt;Today()&lt;/STRONG&gt;, -&lt;STRONG&gt;8&lt;/STRONG&gt;);&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You may also want&lt;/P&gt;
&lt;P&gt;lastSun= intnx('week', today(),-2,"B"); with your result.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You should post code and/log results (code with the errors) into a code box opened with the forum {I} menu icon.&lt;/P&gt;
&lt;P&gt;If you aren't getting errors then show the results you are getting and the expected result.&lt;/P&gt;</description>
      <pubDate>Fri, 12 Jan 2018 00:11:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-pass-a-date-macro-variable-as-a-parameter/m-p/427068#M281355</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2018-01-12T00:11:31Z</dc:date>
    </item>
    <item>
      <title>Re: How do I pass a date macro variable as a parameter</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-pass-a-date-macro-variable-as-a-parameter/m-p/427164#M281356</link>
      <description>&lt;P&gt;You have a couple of problems with the&amp;nbsp;definition and use of your macro variables: The macro variable V3 does not get resolved when put in single quotes ('&amp;amp;V3'), use double quotes: "&amp;amp;V3".&lt;/P&gt;&lt;P&gt;And the call of the %TEST macro has an equal sign too many for V2,&amp;nbsp;"V2==&amp;amp;lastSun".&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Other than that, the code looks OK to me, but I have not tested.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I would use the SYMPUTX&amp;nbsp;routine instead of SYMPUT, though, because you do not get notes about conversion to character, and the value gets automatically trimmed.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 12 Jan 2018 12:36:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-pass-a-date-macro-variable-as-a-parameter/m-p/427164#M281356</guid>
      <dc:creator>s_lassen</dc:creator>
      <dc:date>2018-01-12T12:36:14Z</dc:date>
    </item>
    <item>
      <title>Re: How do I pass a date macro variable as a parameter</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-pass-a-date-macro-variable-as-a-parameter/m-p/427182#M281357</link>
      <description>&lt;P&gt;The only errors I see are not having a % on the LET TODAY= statement at the stop, and having single quotes around the macro variable LEVEL_CD='&amp;amp;V3'.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The v2==&amp;amp;lastSun may be correct, the macro generates: ACTION_DATE&amp;lt; = 21184&amp;nbsp;.&amp;nbsp; I can't remember if the space between the less than sign and equals sign is a problem. If it is, you can remove the space in the macro&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I didn't actually read the code to see if the logic made sense, but I did run it.&lt;/P&gt;
&lt;P&gt;&lt;LI-WRAPPER&gt;&lt;/LI-WRAPPER&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 12 Jan 2018 13:36:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-pass-a-date-macro-variable-as-a-parameter/m-p/427182#M281357</guid>
      <dc:creator>Quentin</dc:creator>
      <dc:date>2018-01-12T13:36:51Z</dc:date>
    </item>
    <item>
      <title>Re: How do I pass a date macro variable as a parameter</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-pass-a-date-macro-variable-as-a-parameter/m-p/427421#M281358</link>
      <description>&lt;P&gt;I almost always prefer to specify date macro values in&amp;nbsp; ddMMMYYYY format (i.e. like&amp;nbsp;&amp;nbsp; 12JAN2018). That way it can be part of a date literal in a sas program, as in:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;%let mydate=01JAN2018;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Then you can use&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; data _null_;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; start_date="&amp;amp;mydate"d;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; .....&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Now, if you want the current date, and if your&amp;nbsp;sas session is newly started (i.e. not left over from yesterday), then just use the automatic macro variable &amp;amp;sysdate9,&amp;nbsp;&amp;nbsp; i.e.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;%let mydate=&amp;amp;sysdate9;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; .....&lt;/P&gt;</description>
      <pubDate>Sat, 13 Jan 2018 05:23:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-pass-a-date-macro-variable-as-a-parameter/m-p/427421#M281358</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2018-01-13T05:23:53Z</dc:date>
    </item>
  </channel>
</rss>

