<?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: Hi I am new to SAS have to call a macro using different values of date in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Hi-I-am-new-to-SAS-have-to-call-a-macro-using-different-values/m-p/189345#M35743</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Use call symputx() to create a macro variable in a data step.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You may also want to look into some date formats such as YYqq format.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 27 Feb 2014 20:28:43 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2014-02-27T20:28:43Z</dc:date>
    <item>
      <title>Hi I am new to SAS have to call a macro using different values of date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Hi-I-am-new-to-SAS-have-to-call-a-macro-using-different-values/m-p/189344#M35742</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;%macro yer();&lt;BR /&gt;data DATE_LKUP;&lt;BR /&gt;MON= month(today());&lt;BR /&gt;YR= YEAR(today());&lt;BR /&gt;IF MON eq 1 then MONTH= 12;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; else MONTH = MON -1;&lt;BR /&gt;IF&amp;nbsp; MON eq 1&lt;BR /&gt; then do;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; Year = YR - 1 ;&amp;nbsp; &lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; end;&lt;BR /&gt; Else &lt;BR /&gt;&amp;nbsp;&amp;nbsp; do;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Year = YR&amp;nbsp; ;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; end;&lt;BR /&gt;If MON eq 1 or MON eq 2 or MON eq 3 then YearQuarter= Year || '-Q1';&lt;BR /&gt; Else If&amp;nbsp; MON eq 4 or MON eq 5 or MON eq 6 then YearQuarter= Year || '-Q2';&lt;BR /&gt; ELSE IF&amp;nbsp; MON eq 7 or MON eq 8 or MON eq 9 then YearQuarter= Year || '-Q3';&lt;BR /&gt; ELSE IF&amp;nbsp; MON eq 10 or MON eq 11 or MON eq 12 then YearQuarter= Year || '-Q4';&lt;BR /&gt;Year1= Year -1;&lt;BR /&gt;Year2= Year -2;&lt;BR /&gt;ReportDATE= Month||'-'||Year;&lt;BR /&gt;%let Year = Year;&lt;BR /&gt;%let Year2 = Year2;&lt;BR /&gt;%let Year1 = Year1;&lt;BR /&gt;%let Month = Month;&lt;BR /&gt;%let YearQrt = YearQuarter;&lt;BR /&gt;%let ReportDATE = ReportDATE;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;%SnapShotDate(&amp;amp;Year,&amp;amp;Month,&amp;amp;YearQrt,3);&lt;BR /&gt;%SnapShotDate(&amp;amp;Year1,&amp;amp;Month,&amp;amp;YearQrt,2);&lt;BR /&gt;%SnapShotDate(&amp;amp;Year2,&amp;amp;Month,&amp;amp;YearQrt,1);&lt;BR /&gt;%BuildExtractFile(&amp;amp;ReportDATE);&lt;BR /&gt;%mend yer;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; font-family: Courier New;"&gt;When I am running this code I am getting below error &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ERROR: CLI describe error: [Microsoft][SQL Server Native Client 10.0][SQL Server]Invalid&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 8pt;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; column name 'Month'. : [Microsoft][SQL Server Native Client 10.0][SQL Server]Invalid&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 8pt;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; column name 'Year'. : [Microsoft][SQL Server Native Client 10.0][SQL&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 8pt;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Server]Statement(s) could not be prepared.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 27 Feb 2014 20:12:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Hi-I-am-new-to-SAS-have-to-call-a-macro-using-different-values/m-p/189344#M35742</guid>
      <dc:creator>ashwary</dc:creator>
      <dc:date>2014-02-27T20:12:20Z</dc:date>
    </item>
    <item>
      <title>Re: Hi I am new to SAS have to call a macro using different values of date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Hi-I-am-new-to-SAS-have-to-call-a-macro-using-different-values/m-p/189345#M35743</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Use call symputx() to create a macro variable in a data step.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You may also want to look into some date formats such as YYqq format.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 27 Feb 2014 20:28:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Hi-I-am-new-to-SAS-have-to-call-a-macro-using-different-values/m-p/189345#M35743</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2014-02-27T20:28:43Z</dc:date>
    </item>
    <item>
      <title>Re: Hi I am new to SAS have to call a macro using different values of date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Hi-I-am-new-to-SAS-have-to-call-a-macro-using-different-values/m-p/189346#M35744</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Looks like the macro %SNAPSHOTDATE() is calling SQL server.&lt;/P&gt;&lt;P&gt;How does this macro expect its parameters formatted?&lt;/P&gt;&lt;P&gt;You do not need the macro %YER() to generate the dates to call the other macro.&amp;nbsp; Either just do the formatting in a data step or even in open code using %SYFUNC() calls.&amp;nbsp; It is not clear what you want to do but if you want to find the previous month or quarter you can use the INTNX() function with a negative offset.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%let today=%sysfunc(today());&lt;/P&gt;&lt;P&gt;%let lastmonth=%sysfunc(intnx(month,&amp;amp;today,-1));&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you want the date in a particular format then use a format on the %SYSFUNC() call.&lt;/P&gt;&lt;P&gt;%let lastqtr = %sysfunc(intnx(month,&amp;amp;today,-1),YYQ6.);&lt;/P&gt;&lt;P&gt;LASTQTR = 2014Q1&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 09 Mar 2014 02:28:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Hi-I-am-new-to-SAS-have-to-call-a-macro-using-different-values/m-p/189346#M35744</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2014-03-09T02:28:24Z</dc:date>
    </item>
  </channel>
</rss>

