<?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: Find last month of previous qurater in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Find-last-month-of-previous-qurater/m-p/489151#M127637</link>
    <description>&lt;P&gt;Use the intnx() function, the yymmn4. format to display quarters from a date, and the input function to convert YYMM into a SAS date that I showed you in your other post.&lt;/P&gt;</description>
    <pubDate>Thu, 23 Aug 2018 07:56:53 GMT</pubDate>
    <dc:creator>Kurt_Bremser</dc:creator>
    <dc:date>2018-08-23T07:56:53Z</dc:date>
    <item>
      <title>Find last month of previous qurater</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Find-last-month-of-previous-qurater/m-p/489149#M127635</link>
      <description>&lt;P&gt;Hello&lt;/P&gt;&lt;P&gt;User define parameter &amp;nbsp;of current month :&lt;/P&gt;&lt;P&gt;%let CurMon=1808;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;SAS should find what is the last month of previous quarter.(and out the value in another parameter called LastQMon)&lt;/P&gt;&lt;P&gt;in this example it should return : &lt;SPAN&gt;LastQMon=&lt;/SPAN&gt;1806&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;other example:&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;%let CurMon=180&lt;/SPAN&gt;&lt;SPAN&gt;7&lt;/SPAN&gt;&lt;SPAN&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;it shoud &amp;nbsp;return &lt;SPAN&gt;LastQMon=&lt;/SPAN&gt;1806&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;other example:&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;%let CurMon=180&lt;/SPAN&gt;&lt;SPAN&gt;5&lt;/SPAN&gt;&lt;SPAN&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;it shoud &amp;nbsp;return &lt;SPAN&gt;LastQMon=&lt;/SPAN&gt;1803&lt;/P&gt;</description>
      <pubDate>Thu, 23 Aug 2018 07:53:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Find-last-month-of-previous-qurater/m-p/489149#M127635</guid>
      <dc:creator>Ronein</dc:creator>
      <dc:date>2018-08-23T07:53:37Z</dc:date>
    </item>
    <item>
      <title>Re: Find last month of previous qurater</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Find-last-month-of-previous-qurater/m-p/489151#M127637</link>
      <description>&lt;P&gt;Use the intnx() function, the yymmn4. format to display quarters from a date, and the input function to convert YYMM into a SAS date that I showed you in your other post.&lt;/P&gt;</description>
      <pubDate>Thu, 23 Aug 2018 07:56:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Find-last-month-of-previous-qurater/m-p/489151#M127637</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-08-23T07:56:53Z</dc:date>
    </item>
    <item>
      <title>Re: Find last month of previous qurater</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Find-last-month-of-previous-qurater/m-p/489160#M127645</link>
      <description>&lt;P&gt;Thanks a lot.&lt;/P&gt;&lt;P&gt;I created the code by your tip.&lt;/P&gt;&lt;P&gt;Now there is another problem.&lt;/P&gt;&lt;P&gt;As you can see in parameter &amp;amp;vector &amp;nbsp; the last argument is coming with many spaces.&lt;/P&gt;&lt;P&gt;I don't understand why because sas parameter should remove spaces&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/*Current month*/
%let CurMon=1807;
%put &amp;amp;CurMon;/*1807*/

%let CurMon_date=%sysfunc(inputn(&amp;amp;CurMon.,yymmn4.));
%put &amp;amp;CurMon_date;/*21366*/

/*Previous month*/
%let PrevMon=%sysfunc(intnx(MONTH,&amp;amp;CurMon_date,-1),yymmN4.);
%put &amp;amp;PrevMon;/*1806*/

/*Same month previous year*/
%let SameMonPrevYear=%sysfunc(intnx(MONTH,&amp;amp;CurMon_date,-12),yymmN4.);
%put &amp;amp;SameMonPrevYear;/*1707*/

/*Last DEC*/
Data _null_;
yy=substr(compress(&amp;amp;CurMon.),1,2)-1;
mm=12;
yymm=CAT(yy,mm);
call symput('lastDECMon',yymm);
run;
%put &amp;amp;lastDECMon;/*1712*/

/*Last month in previous qurater*/
data _null_;
f=intnx('quarter',&amp;amp;CurMon_date.,-1);
f2=intnx('quarter',f,0,'e');
f3=put(f2,yymmn4.);
call symput('PrevQ',f3);
format f f2 date9.;
run;
%put &amp;amp;PrevQ;/*1806*/

/*Vector of months*/
%let vector=&amp;amp;CurMon+&amp;amp;PrevMon+&amp;amp;lastDECMon+&amp;amp;PrevQ;
%put &amp;amp;vector; &lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 23 Aug 2018 08:38:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Find-last-month-of-previous-qurater/m-p/489160#M127645</guid>
      <dc:creator>Ronein</dc:creator>
      <dc:date>2018-08-23T08:38:45Z</dc:date>
    </item>
    <item>
      <title>Re: Find last month of previous qurater</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Find-last-month-of-previous-qurater/m-p/489167#M127652</link>
      <description>&lt;P&gt;Your problem is here:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Data _null_;
yy=substr(compress(&amp;amp;CurMon.),1,2)-1;
mm=12;
yymm=CAT(yy,mm);
call symput('lastDECMon',yymm);
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Since you did not set a specific length for yymm, and used a function, SAS defined it with the default length of 200. So you get 4 digits and 196 spaces.&lt;/P&gt;
&lt;P&gt;Either use the trim() function in call symput, or the call symputx() function (which trims automatically), or set a specific length for yymm.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;See Maxim 47.&lt;/P&gt;</description>
      <pubDate>Thu, 23 Aug 2018 08:52:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Find-last-month-of-previous-qurater/m-p/489167#M127652</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-08-23T08:52:56Z</dc:date>
    </item>
    <item>
      <title>Re: Find last month of previous qurater</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Find-last-month-of-previous-qurater/m-p/489168#M127653</link>
      <description>&lt;P&gt;Why do you not write one post, and state what you want, and what you have.&amp;nbsp; You have several posts on the same topic here, all of which are not needed.&amp;nbsp;&amp;nbsp;&lt;U&gt;&lt;STRONG&gt;Macro is not a replacement for Base SAS.&lt;/STRONG&gt;&lt;/U&gt;&lt;/P&gt;
&lt;P&gt;As such that code is virtually indecipherable and not needed.&amp;nbsp; For instance the post here:&lt;/P&gt;
&lt;P&gt;&lt;A href="https://communities.sas.com/t5/SAS-Programming/create-date-parameters/m-p/489156" target="_blank"&gt;https://communities.sas.com/t5/SAS-Programming/create-date-parameters/m-p/489156&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;Is exactly the same thing, with a slightly different output.&lt;/P&gt;</description>
      <pubDate>Thu, 23 Aug 2018 08:53:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Find-last-month-of-previous-qurater/m-p/489168#M127653</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2018-08-23T08:53:04Z</dc:date>
    </item>
    <item>
      <title>Re: Find last month of previous qurater</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Find-last-month-of-previous-qurater/m-p/489176#M127658</link>
      <description>&lt;P&gt;Thank you so so much!&lt;/P&gt;</description>
      <pubDate>Thu, 23 Aug 2018 09:29:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Find-last-month-of-previous-qurater/m-p/489176#M127658</guid>
      <dc:creator>Ronein</dc:creator>
      <dc:date>2018-08-23T09:29:44Z</dc:date>
    </item>
  </channel>
</rss>

