<?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: Can qtr function taking macro in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Can-qtr-function-taking-macro/m-p/104324#M21797</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks, Linlin.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It worked correctly!&amp;nbsp; Just a thought if I use date( ) or today( ) as cutoff date instead of specific date(09/01/2012), so no need to change date every time later on. What function or macro do you suggest to use?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 25 Oct 2012 19:45:15 GMT</pubDate>
    <dc:creator>leisas</dc:creator>
    <dc:date>2012-10-25T19:45:15Z</dc:date>
    <item>
      <title>Can qtr function taking macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Can-qtr-function-taking-macro/m-p/104309#M21782</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Basically, I need to get a quarter of the year, for instance, the third quarter (number 3) of this year.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If I use data step, it works fine&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data quatr;&lt;/P&gt;&lt;P&gt;x=%sysfunc(putn("&amp;amp;sysdate9"d,5.));&lt;/P&gt;&lt;P&gt;q=qtr(x)-1;&lt;/P&gt;&lt;P&gt;RUN;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;result q is 3&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;What I really need is a macro of quarter so I can innovate in my program. I coded as&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%LET QT=QTR(%sysfunc(putn("&amp;amp;sysdate9"d,5.)))-1;&lt;BR /&gt;%put qt=&amp;amp;qt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;result in log&lt;/P&gt;&lt;P&gt;qt=QTR(19289)-1&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;My question is if data step is the only way to use QTR function, how to create macro of qtr? Thanks!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 23 Oct 2012 19:00:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Can-qtr-function-taking-macro/m-p/104309#M21782</guid>
      <dc:creator>leisas</dc:creator>
      <dc:date>2012-10-23T19:00:54Z</dc:date>
    </item>
    <item>
      <title>Re: Can qtr function taking macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Can-qtr-function-taking-macro/m-p/104310#M21783</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;%LET QT=%eval(%sysfunc(QTR(%sysfunc(putn("&amp;amp;sysdate9"d,5.))))-1);&lt;/P&gt;&lt;P&gt;%put qt=&amp;amp;qt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Haikuo &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 23 Oct 2012 19:19:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Can-qtr-function-taking-macro/m-p/104310#M21783</guid>
      <dc:creator>Haikuo</dc:creator>
      <dc:date>2012-10-23T19:19:58Z</dc:date>
    </item>
    <item>
      <title>Re: Can qtr function taking macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Can-qtr-function-taking-macro/m-p/104311#M21784</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Got it. Thanks a lot!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 23 Oct 2012 19:25:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Can-qtr-function-taking-macro/m-p/104311#M21784</guid>
      <dc:creator>leisas</dc:creator>
      <dc:date>2012-10-23T19:25:48Z</dc:date>
    </item>
    <item>
      <title>Re: Can qtr function taking macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Can-qtr-function-taking-macro/m-p/104312#M21785</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;It could be simpler.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%LET QT=%eval(%sysfunc(today(),qtr.)-1);&lt;/P&gt;&lt;P&gt;%put qt=&amp;amp;qt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Ksharp&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 24 Oct 2012 04:03:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Can-qtr-function-taking-macro/m-p/104312#M21785</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2012-10-24T04:03:12Z</dc:date>
    </item>
    <item>
      <title>Re: Can qtr function taking macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Can-qtr-function-taking-macro/m-p/104313#M21786</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;No need to use PUTN on date literals.&amp;nbsp; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;%let qt=%eval(%sysfunc(qtr("&amp;amp;sysdate9"d))-1);&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;But the %EVAL() is needed because the original requester had done it that way.&amp;nbsp; Not sure why they want to number quarters from 0 to 3 instead of from 1 to 4. &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 24 Oct 2012 04:12:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Can-qtr-function-taking-macro/m-p/104313#M21786</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2012-10-24T04:12:39Z</dc:date>
    </item>
    <item>
      <title>Re: Can qtr function taking macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Can-qtr-function-taking-macro/m-p/104314#M21787</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Why is your data step mixing macro and normal SAS functions? &lt;/P&gt;&lt;P&gt;If you want to use the automatic macro variable SYSDATE9 in a Data step there is normally not a need to convert it first with macro programming statements.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-family: 'courier new', courier; font-size: 12pt;"&gt;data quatr;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-family: 'courier new', courier; font-size: 12pt;"&gt; q=qtr("&amp;amp;sysdate9"d)-1;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-family: 'courier new', courier; font-size: 12pt;"&gt;run;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-family: 'courier new', courier; font-size: 12pt;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 24 Oct 2012 04:21:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Can-qtr-function-taking-macro/m-p/104314#M21787</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2012-10-24T04:21:11Z</dc:date>
    </item>
    <item>
      <title>Re: Can qtr function taking macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Can-qtr-function-taking-macro/m-p/104315#M21788</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Yes, it is simpler and worked. Thank you!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 24 Oct 2012 15:09:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Can-qtr-function-taking-macro/m-p/104315#M21788</guid>
      <dc:creator>leisas</dc:creator>
      <dc:date>2012-10-24T15:09:51Z</dc:date>
    </item>
    <item>
      <title>Re: Can qtr function taking macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Can-qtr-function-taking-macro/m-p/104316#M21789</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;qtr("&amp;amp;sysdate9"d ) returnes the current quarter num which is 4, but I need the third quarter, so need -1.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 24 Oct 2012 15:13:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Can-qtr-function-taking-macro/m-p/104316#M21789</guid>
      <dc:creator>leisas</dc:creator>
      <dc:date>2012-10-24T15:13:33Z</dc:date>
    </item>
    <item>
      <title>Re: Can qtr function taking macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Can-qtr-function-taking-macro/m-p/104317#M21790</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You're correct. I did the extra step just want to see what I would get so as qtr function can take and convert.&amp;nbsp; Your code is absolute correct and effecient. Thanks a lot!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 24 Oct 2012 15:22:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Can-qtr-function-taking-macro/m-p/104317#M21790</guid>
      <dc:creator>leisas</dc:creator>
      <dc:date>2012-10-24T15:22:54Z</dc:date>
    </item>
    <item>
      <title>Re: Can qtr function taking macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Can-qtr-function-taking-macro/m-p/104318#M21791</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If you want to find the previous quarter then you should look into using the INTNX function.&lt;/P&gt;&lt;P&gt;For example what will happen when the current date is in January?&amp;nbsp; Do you want to get 0 or 4 as the returned quarter number?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;%let refdate=01JAN2012;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;%let prev_qtr=%sysfunc(intnx(qtr,"&amp;amp;refdate"d,-1),qtr.);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;%put &amp;amp;prev_qtr;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 24 Oct 2012 16:05:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Can-qtr-function-taking-macro/m-p/104318#M21791</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2012-10-24T16:05:16Z</dc:date>
    </item>
    <item>
      <title>Re: Can qtr function taking macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Can-qtr-function-taking-macro/m-p/104319#M21792</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Tom,&lt;/P&gt;&lt;P&gt;Your most recent code really help me with the question I had for a quite long time. I had the problem if the date went back across "Year". Now you resolved the problem. Thank you SO much!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 25 Oct 2012 13:15:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Can-qtr-function-taking-macro/m-p/104319#M21792</guid>
      <dc:creator>leisas</dc:creator>
      <dc:date>2012-10-25T13:15:02Z</dc:date>
    </item>
    <item>
      <title>Re: Can qtr function taking macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Can-qtr-function-taking-macro/m-p/104320#M21793</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Tom,&lt;/P&gt;&lt;P&gt;I see your macro returns previous year, month or quarter correctly by using date function. Any way I can get by 'yyyymm' or 'mm/dd/yyyy'?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __jive_macro_name="quote" class="jive_text_macro jive_macro_quote"&gt;
&lt;P&gt;Tom wrote:&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;If you want to find the previous quarter then you should look into using the INTNX function.&lt;/P&gt;
&lt;P&gt;For example what will happen when the current date is in January?&amp;nbsp; Do you want to get 0 or 4 as the returned quarter number?&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;%let refdate=01JAN2012;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;%let prev_qtr=%sysfunc(intnx(qtr,"&amp;amp;refdate"d,-1),qtr.);&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;%put &amp;amp;prev_qtr;&lt;/SPAN&gt;&lt;/P&gt;
&lt;/PRE&gt;&lt;P&gt;For instance, our data provide date formatted as 'yyyymm' - '201209'&amp;nbsp; or 'mm/dd/yyyy' - '09/01/2012'. Can I get the same date formate one year backward?, say ''201110'&lt;/P&gt;&lt;P&gt;or '09/01/2011'? from some macros or functions?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt; &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 25 Oct 2012 18:37:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Can-qtr-function-taking-macro/m-p/104320#M21793</guid>
      <dc:creator>leisas</dc:creator>
      <dc:date>2012-10-25T18:37:01Z</dc:date>
    </item>
    <item>
      <title>Re: Can qtr function taking macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Can-qtr-function-taking-macro/m-p/104321#M21794</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt; is this what you want?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;69&amp;nbsp; %let refdate=09/01/2012;&lt;/P&gt;&lt;P&gt;270&lt;/P&gt;&lt;P&gt;271&amp;nbsp; %let prev_year=%sysfunc(intnx(year,%sysfunc(inputn(&amp;amp;refdate,mmddyy10.)),-1),year.);&lt;/P&gt;&lt;P&gt;272&lt;/P&gt;&lt;P&gt;273&amp;nbsp; %put &amp;amp;prev_year;&lt;/P&gt;&lt;P&gt;2011&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 25 Oct 2012 18:47:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Can-qtr-function-taking-macro/m-p/104321#M21794</guid>
      <dc:creator>Linlin</dc:creator>
      <dc:date>2012-10-25T18:47:09Z</dc:date>
    </item>
    <item>
      <title>Re: Can qtr function taking macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Can-qtr-function-taking-macro/m-p/104322#M21795</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;No. I used the similar code before, only returned yyyy which in this case is 2011. I hope to get '09/01/2011' or '201109' for instance.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 25 Oct 2012 19:02:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Can-qtr-function-taking-macro/m-p/104322#M21795</guid>
      <dc:creator>leisas</dc:creator>
      <dc:date>2012-10-25T19:02:52Z</dc:date>
    </item>
    <item>
      <title>Re: Can qtr function taking macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Can-qtr-function-taking-macro/m-p/104323#M21796</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;299&amp;nbsp; %let refdate=09/01/2012;&lt;/P&gt;&lt;P&gt;300&lt;/P&gt;&lt;P&gt;301&amp;nbsp; %let prev_year=%sysfunc(intnx(year,%sysfunc(inputn(&amp;amp;refdate,mmddyy10.)),-1,s),mmddyy10.);&lt;/P&gt;&lt;P&gt;302&lt;/P&gt;&lt;P&gt;303&amp;nbsp; %put &amp;amp;prev_year;&lt;/P&gt;&lt;P&gt;09/01/2011&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 25 Oct 2012 19:08:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Can-qtr-function-taking-macro/m-p/104323#M21796</guid>
      <dc:creator>Linlin</dc:creator>
      <dc:date>2012-10-25T19:08:18Z</dc:date>
    </item>
    <item>
      <title>Re: Can qtr function taking macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Can-qtr-function-taking-macro/m-p/104324#M21797</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks, Linlin.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It worked correctly!&amp;nbsp; Just a thought if I use date( ) or today( ) as cutoff date instead of specific date(09/01/2012), so no need to change date every time later on. What function or macro do you suggest to use?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 25 Oct 2012 19:45:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Can-qtr-function-taking-macro/m-p/104324#M21797</guid>
      <dc:creator>leisas</dc:creator>
      <dc:date>2012-10-25T19:45:15Z</dc:date>
    </item>
    <item>
      <title>Re: Can qtr function taking macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Can-qtr-function-taking-macro/m-p/104325#M21798</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;312&amp;nbsp; %let prev_year=%sysfunc(intnx(year,%sysfunc(today()),-1,s),mmddyy10.);&lt;/P&gt;&lt;P&gt;313&lt;/P&gt;&lt;P&gt;314&amp;nbsp; %put &amp;amp;prev_year;&lt;/P&gt;&lt;P&gt;10/25/2011&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 25 Oct 2012 19:51:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Can-qtr-function-taking-macro/m-p/104325#M21798</guid>
      <dc:creator>Linlin</dc:creator>
      <dc:date>2012-10-25T19:51:18Z</dc:date>
    </item>
    <item>
      <title>Re: Can qtr function taking macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Can-qtr-function-taking-macro/m-p/104326#M21799</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;It worked perfectly! Thanks, Linlin!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 25 Oct 2012 19:58:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Can-qtr-function-taking-macro/m-p/104326#M21799</guid>
      <dc:creator>leisas</dc:creator>
      <dc:date>2012-10-25T19:58:26Z</dc:date>
    </item>
    <item>
      <title>Re: Can qtr function taking macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Can-qtr-function-taking-macro/m-p/104327#M21800</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier; background-color: #ffffff;"&gt;%let prev_qtr=%sysfunc(intnx(qtr,"&amp;amp;refdate"d,-1),qtr.);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Break down the statement into its pieces so you can see how to make the changes you want.&amp;nbsp; The second argument to the %SYSFUNC() function is the format that you want to use in creating the new macro variable.&amp;nbsp; So QTR. format returns the quarter number.&amp;nbsp; You could use YEAR. to get just the year.&amp;nbsp; Or DATE9 . You could use MMDDYY10. format to get 09/01/2012.&amp;nbsp; You could use YYMMN6. to get it as 201209.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Now if you want to change how the input macro variable is formatted then you need to change how you are passing in the second parameter of the INTNX() function call. The line above is using a date literal to feed the date value into the INTNX() function.&amp;nbsp; Date literals require ddMONyy or ddMONyyyy format.&amp;nbsp; But you can use another nested %SYSFUNC() macro call to allow you to use the INPUTN() function to convert strings in other date formats into date values.&amp;nbsp; For example you could use %sysfunc(inputn(09/01/2012,mmddyy10.)).&lt;/P&gt;&lt;P&gt;To read 201209 as a valid date is a little harder.&amp;nbsp; Try this.&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;%let refdate=201209 ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;%put %sysfunc(inputn(&amp;amp;refdate.01,yymmdd8.));&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here are examples using three input formats: 25OCT2012, 10/25/2012 and 201210 and outputting using YEAR., QTR., DATE9., MMDDYY10., and YYMMN6. formats.&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;%let refdate=&amp;amp;sysdate9;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;%put &amp;amp;refdate;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;%put %sysfunc(intnx(qtr,"&amp;amp;refdate"d,-1),year.);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;%put %sysfunc(intnx(qtr,"&amp;amp;refdate"d,-1),qtr.);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;%put %sysfunc(intnx(qtr,"&amp;amp;refdate"d,-1),date9.);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;%put %sysfunc(intnx(qtr,"&amp;amp;refdate"d,-1),mmddyy10.);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;%put %sysfunc(intnx(qtr,"&amp;amp;refdate"d,-1),yymmn6.);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;%let refdate=10/25/2012;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;%put &amp;amp;refdate;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;%put %sysfunc(intnx(qtr,%sysfunc(inputn(&amp;amp;refdate,mmddyy10.)),-1),year.);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;%put %sysfunc(intnx(qtr,%sysfunc(inputn(&amp;amp;refdate,mmddyy10.)),-1),qtr.);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;%put %sysfunc(intnx(qtr,%sysfunc(inputn(&amp;amp;refdate,mmddyy10.)),-1),date9.);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;%put %sysfunc(intnx(qtr,%sysfunc(inputn(&amp;amp;refdate,mmddyy10.)),-1),mmddyy10.);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;%put %sysfunc(intnx(qtr,%sysfunc(inputn(&amp;amp;refdate,mmddyy10.)),-1),yymmn6.);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;%let refdate=201210;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;%put &amp;amp;refdate;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;%put %sysfunc(intnx(qtr,%sysfunc(inputn(&amp;amp;refdate.01,yymmdd8.)),-1),year.);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;%put %sysfunc(intnx(qtr,%sysfunc(inputn(&amp;amp;refdate.01,yymmdd8.)),-1),qtr.);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;%put %sysfunc(intnx(qtr,%sysfunc(inputn(&amp;amp;refdate.01,yymmdd8.)),-1),date9.);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;%put %sysfunc(intnx(qtr,%sysfunc(inputn(&amp;amp;refdate.01,yymmdd8.)),-1),mmddyy10.);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;%put %sysfunc(intnx(qtr,%sysfunc(inputn(&amp;amp;refdate.01,yymmdd8.)),-1),yymmn6.);&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 25 Oct 2012 20:49:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Can-qtr-function-taking-macro/m-p/104327#M21800</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2012-10-25T20:49:04Z</dc:date>
    </item>
    <item>
      <title>Re: Can qtr function taking macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Can-qtr-function-taking-macro/m-p/104328#M21801</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Tom,&lt;/P&gt;&lt;P&gt;Thank you SO MUCH for the detailed explaination and codes. They are very helpful indeed. I coded some of in my program, it worked perfectly. Again, Thank you for looking into my post and helped me out of the woods in time.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Leigh&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 26 Oct 2012 14:57:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Can-qtr-function-taking-macro/m-p/104328#M21801</guid>
      <dc:creator>leisas</dc:creator>
      <dc:date>2012-10-26T14:57:07Z</dc:date>
    </item>
  </channel>
</rss>

