<?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 macro variable dates in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/macro-variable-dates/m-p/51640#M10865</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello SAS users,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am doing a condition check here, if the code run day is sunday i want to take the sunday dt and output in&amp;nbsp; 'm/dd/yyyy' format. If it is not sunday I want to take the run date and do a day -1 and output in&amp;nbsp; 'mm/dd/yyyy' as well. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am getting the below error and not sure what I am doing wrong.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 8pt;"&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;ERROR: Expected close parenthesis after macro function invocation not found.&lt;/P&gt;&lt;P&gt;ERROR: The function PUTN referenced by the %SYSFUNC or %QSYSFUNC macro function has too few&lt;/P&gt;&lt;P&gt;Would anyone have any idea?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%Macro c;&lt;BR /&gt;Data _null_;&lt;/P&gt;&lt;P&gt;%If %sysfunc(weekday(%sysfunc(today()))) = 1 %then %Let dt = %str(%')%sysfunc(putn(%sysfunc(today()),mmddyys10.))%str(%');&amp;nbsp; &lt;BR /&gt;%else %Let dt = %str(%')%sysfunc(putn(%sysfunc(today(),-1),mmddyys10.))%str(%'); &lt;BR /&gt;Run;&lt;/P&gt;&lt;P&gt;%Put dt= &amp;amp;dt.;&lt;BR /&gt;%Mend c;&lt;BR /&gt;%c;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;arguments.&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 8pt;"&gt;﻿&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sat, 31 Mar 2012 20:02:56 GMT</pubDate>
    <dc:creator>vicky07</dc:creator>
    <dc:date>2012-03-31T20:02:56Z</dc:date>
    <item>
      <title>macro variable dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/macro-variable-dates/m-p/51640#M10865</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello SAS users,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am doing a condition check here, if the code run day is sunday i want to take the sunday dt and output in&amp;nbsp; 'm/dd/yyyy' format. If it is not sunday I want to take the run date and do a day -1 and output in&amp;nbsp; 'mm/dd/yyyy' as well. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am getting the below error and not sure what I am doing wrong.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 8pt;"&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;ERROR: Expected close parenthesis after macro function invocation not found.&lt;/P&gt;&lt;P&gt;ERROR: The function PUTN referenced by the %SYSFUNC or %QSYSFUNC macro function has too few&lt;/P&gt;&lt;P&gt;Would anyone have any idea?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%Macro c;&lt;BR /&gt;Data _null_;&lt;/P&gt;&lt;P&gt;%If %sysfunc(weekday(%sysfunc(today()))) = 1 %then %Let dt = %str(%')%sysfunc(putn(%sysfunc(today()),mmddyys10.))%str(%');&amp;nbsp; &lt;BR /&gt;%else %Let dt = %str(%')%sysfunc(putn(%sysfunc(today(),-1),mmddyys10.))%str(%'); &lt;BR /&gt;Run;&lt;/P&gt;&lt;P&gt;%Put dt= &amp;amp;dt.;&lt;BR /&gt;%Mend c;&lt;BR /&gt;%c;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;arguments.&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 8pt;"&gt;﻿&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 31 Mar 2012 20:02:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/macro-variable-dates/m-p/51640#M10865</guid>
      <dc:creator>vicky07</dc:creator>
      <dc:date>2012-03-31T20:02:56Z</dc:date>
    </item>
    <item>
      <title>Re: macro variable dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/macro-variable-dates/m-p/51641#M10866</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If you are running a data step they why are you bothering with macro statements?&lt;/P&gt;&lt;PRE __jive_macro_name="quote" class="jive_text_macro jive_macro_quote"&gt;&lt;P&gt;%Macro c;&lt;BR /&gt;Data _null_;&lt;/P&gt;&lt;P&gt;%If %sysfunc(weekday(%sysfunc(today()))) = 1 %then %Let dt = %str(%')%sysfunc(putn(%sysfunc(today()),mmddyys10.))%str(%');&amp;nbsp; &lt;BR /&gt;%else %Let dt = %str(%')%sysfunc(putn(%sysfunc(today(),-1),mmddyys10.))%str(%'); &lt;BR /&gt;Run;&lt;/P&gt;&lt;P&gt;%Put dt= &amp;amp;dt.;&lt;BR /&gt;%Mend c;&lt;BR /&gt;%c;&lt;SPAN style="font-size: 8pt;"&gt;﻿&lt;/SPAN&gt;&lt;/P&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="plain" __jive_macro_name="code" class="jive_text_macro jive_macro_code"&gt;&lt;P&gt;data _null_;&lt;/P&gt;&lt;P&gt;&amp;nbsp; call symputx('dt',"'"||put(today()-(1 = &lt;SPAN style="font-family: monospace; white-space: pre; background-color: #ffffff;"&gt;weekday(today()))&lt;/SPAN&gt;,mmddyys10.)||"'");&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 31 Mar 2012 20:14:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/macro-variable-dates/m-p/51641#M10866</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2012-03-31T20:14:53Z</dc:date>
    </item>
    <item>
      <title>Re: macro variable dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/macro-variable-dates/m-p/51642#M10867</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I second Tom. On the other hand, you don't need data step to make it happen either:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%Macro c;&lt;/P&gt;&lt;P&gt;/*Data _null_;*/&lt;/P&gt;&lt;P&gt;%If %sysfunc(weekday(%sysfunc(today()))) = 1 %then %Let dt = %str(%')%sysfunc(putn(%sysfunc(today()),mmddyy10.))%str(%'); &lt;/P&gt;&lt;P&gt;%else %Let dt = %str(%')%sysfunc(putn(%eval(%sysfunc(today())-1),mmddyy10.))%str(%');&lt;/P&gt;&lt;P&gt;/*Run; */&lt;/P&gt;&lt;P&gt;%Put dt= &amp;amp;dt.;&lt;/P&gt;&lt;P&gt;%Mend c;&lt;/P&gt;&lt;P&gt;%c&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The only thing was missing is %eval.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Haikuo&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 31 Mar 2012 20:34:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/macro-variable-dates/m-p/51642#M10867</guid>
      <dc:creator>Haikuo</dc:creator>
      <dc:date>2012-03-31T20:34:30Z</dc:date>
    </item>
    <item>
      <title>Re: macro variable dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/macro-variable-dates/m-p/51643#M10868</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Don't need a macro either as there is no macro logic involved.&lt;/P&gt;&lt;P&gt;You can make the nested %SYSFUNC() calls easier by first getting the numeric version of today's date.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="plain" __jive_macro_name="code" class="jive_text_macro jive_macro_code"&gt;&lt;P&gt;%let dt=%sysfunc(today());&lt;/P&gt;&lt;P&gt;%let dt=%str(%')%sysfunc(putn(&amp;amp;dt-(1=%sysfunc(weekday(&amp;amp;dt))),mmddyys10.))%str(%');&lt;/P&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Note the %EVAL is not required in the arguments passed to the function that %SYSFUNC() is calling.&amp;nbsp; The function can evaluate expressions just as it does when called in a data step.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 31 Mar 2012 20:50:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/macro-variable-dates/m-p/51643#M10868</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2012-03-31T20:50:30Z</dc:date>
    </item>
  </channel>
</rss>

