<?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 series of YYMM in end of quarters between start to end in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/series-of-YYMM-in-end-of-quarters-between-start-to-end/m-p/489124#M127613</link>
    <description>&lt;P&gt;Hello&lt;/P&gt;&lt;P&gt;In this example the user enter two dates (start and end in format YYMM) .&lt;/P&gt;&lt;P&gt;The target is to get all end of quarter months between start and end.&lt;/P&gt;&lt;P&gt;for example:&lt;/P&gt;&lt;P&gt;start=1612&lt;/P&gt;&lt;P&gt;end=1808&lt;/P&gt;&lt;P&gt;We should get &amp;nbsp;1612 &amp;nbsp;1703 &amp;nbsp;1706 &amp;nbsp;1709 &amp;nbsp;1712 &amp;nbsp;1803 &amp;nbsp;1806&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In the following code the problem is that we get also 1809 (which is bigger than end )&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;One more problem is that when I run&amp;nbsp;%PUT &amp;amp;&amp;amp;m&amp;amp;n..; &amp;nbsp;I get &amp;nbsp;warning &amp;nbsp;"WARNING: Apparent symbolic reference M not resolved."&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let start=1612; /*Must start from end of quarter :Dec March June Sep*/
%let end=1807; 

%let date_start=%sysfunc(inputn(&amp;amp;start.,yymmn4.));
%let date_end=%sysfunc(inputn(&amp;amp;end.,yymmn4.));
%put &amp;amp;date_start.;
%put &amp;amp;date_end.;


Data want_month;
do j=0 to intck('QUARTER',&amp;amp;date_start.,&amp;amp;date_end.) ;
ddate=intnx('QUARTER', &amp;amp;date_start., j, 's');
char_ddate = put(ddate, YYMMn4.);
/*Var_Macro_name=compress('m'||put(J,2.));*/
Var_Macro_name='m'||strip(put(J,2.));
call symputx('m'||strip(put(J,2.)), char_ddate);
output;
end;
Run;


PROC SQL Noprint;
select count(*)  INTO:n 	   
	from want_month
;
QUIT;
%put &amp;amp;n.;
%put &amp;amp;m0;
%put &amp;amp;m1;
%PUT &amp;amp;&amp;amp;m&amp;amp;n..;

&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Thu, 23 Aug 2018 04:43:02 GMT</pubDate>
    <dc:creator>Ronein</dc:creator>
    <dc:date>2018-08-23T04:43:02Z</dc:date>
    <item>
      <title>series of YYMM in end of quarters between start to end</title>
      <link>https://communities.sas.com/t5/SAS-Programming/series-of-YYMM-in-end-of-quarters-between-start-to-end/m-p/489124#M127613</link>
      <description>&lt;P&gt;Hello&lt;/P&gt;&lt;P&gt;In this example the user enter two dates (start and end in format YYMM) .&lt;/P&gt;&lt;P&gt;The target is to get all end of quarter months between start and end.&lt;/P&gt;&lt;P&gt;for example:&lt;/P&gt;&lt;P&gt;start=1612&lt;/P&gt;&lt;P&gt;end=1808&lt;/P&gt;&lt;P&gt;We should get &amp;nbsp;1612 &amp;nbsp;1703 &amp;nbsp;1706 &amp;nbsp;1709 &amp;nbsp;1712 &amp;nbsp;1803 &amp;nbsp;1806&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In the following code the problem is that we get also 1809 (which is bigger than end )&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;One more problem is that when I run&amp;nbsp;%PUT &amp;amp;&amp;amp;m&amp;amp;n..; &amp;nbsp;I get &amp;nbsp;warning &amp;nbsp;"WARNING: Apparent symbolic reference M not resolved."&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let start=1612; /*Must start from end of quarter :Dec March June Sep*/
%let end=1807; 

%let date_start=%sysfunc(inputn(&amp;amp;start.,yymmn4.));
%let date_end=%sysfunc(inputn(&amp;amp;end.,yymmn4.));
%put &amp;amp;date_start.;
%put &amp;amp;date_end.;


Data want_month;
do j=0 to intck('QUARTER',&amp;amp;date_start.,&amp;amp;date_end.) ;
ddate=intnx('QUARTER', &amp;amp;date_start., j, 's');
char_ddate = put(ddate, YYMMn4.);
/*Var_Macro_name=compress('m'||put(J,2.));*/
Var_Macro_name='m'||strip(put(J,2.));
call symputx('m'||strip(put(J,2.)), char_ddate);
output;
end;
Run;


PROC SQL Noprint;
select count(*)  INTO:n 	   
	from want_month
;
QUIT;
%put &amp;amp;n.;
%put &amp;amp;m0;
%put &amp;amp;m1;
%PUT &amp;amp;&amp;amp;m&amp;amp;n..;

&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 23 Aug 2018 04:43:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/series-of-YYMM-in-end-of-quarters-between-start-to-end/m-p/489124#M127613</guid>
      <dc:creator>Ronein</dc:creator>
      <dc:date>2018-08-23T04:43:02Z</dc:date>
    </item>
    <item>
      <title>Re: series of YYMM in end of quarters between start to end</title>
      <link>https://communities.sas.com/t5/SAS-Programming/series-of-YYMM-in-end-of-quarters-between-start-to-end/m-p/489126#M127615</link>
      <description>&lt;P&gt;please try the below i applied the filter&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;new=%sysfunc(inputn(&amp;amp;end.,best.));&lt;BR /&gt;if input(char_ddate,best.)&amp;lt;new;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let start=1612; /*Must start from end of quarter :Dec March June Sep*/
%let end=1807; 

%let date_start=%sysfunc(inputn(&amp;amp;start.,yymmn4.));
%let date_end=%sysfunc(inputn(&amp;amp;end.,yymmn4.));
%put &amp;amp;date_start.;
%put &amp;amp;date_end.;


Data want_month;
do j=0 to intck('QUARTER',&amp;amp;date_start.,&amp;amp;date_end.) ;
ddate=intnx('QUARTER', &amp;amp;date_start., j, 's');
char_ddate = put(ddate, YYMMn4.);
/*Var_Macro_name=compress('m'||put(J,2.));*/
Var_Macro_name='m'||strip(put(J,2.));
call symputx('m'||strip(put(J,2.)), char_ddate);
new=%sysfunc(inputn(&amp;amp;end.,best.));
if input(char_ddate,best.)&amp;lt;new;
output;
end;
format ddate date9.;
Run;


PROC SQL Noprint;
select count(*)  INTO:n 	   
	from want_month
;
QUIT;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 23 Aug 2018 05:25:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/series-of-YYMM-in-end-of-quarters-between-start-to-end/m-p/489126#M127615</guid>
      <dc:creator>Jagadishkatam</dc:creator>
      <dc:date>2018-08-23T05:25:28Z</dc:date>
    </item>
    <item>
      <title>Re: series of YYMM in end of quarters between start to end</title>
      <link>https://communities.sas.com/t5/SAS-Programming/series-of-YYMM-in-end-of-quarters-between-start-to-end/m-p/489148#M127634</link>
      <description>&lt;P&gt;Use a do while loop, it is simpler to read:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let start=1612;
%let end=1807;

data want_month (keep=quarter);
length quarter $4;
quarterdate = intnx('quarter',input("20&amp;amp;start.01",yymmdd8.),0,'e');
n = 1;
do while (quarterdate le input("20&amp;amp;end.01",yymmdd8.));
  quarter = put(quarterdate,yymmn4.);
  call symputx('m'||strip(put(n,2.)),quarter);
  output;
  quarterdate = intnx('quarter',quarterdate,1,'e');
  n + 1;
end;
run;

%put _global_;

PROC SQL Noprint;
select count(*)  INTO:n 	   
	from want_month
;
QUIT;

%let n=&amp;amp;n; * removes leading blanks;
%put &amp;amp;m1;
%put &amp;amp;&amp;amp;m&amp;amp;n;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Note how to fix the problem with &amp;amp;&amp;amp;m&amp;amp;n. Without the %let n=&amp;amp;n, you see this in the log:&lt;/P&gt;
&lt;PRE&gt;53         %put &amp;amp;&amp;amp;m&amp;amp;n;
WARNING: Apparent symbolic reference M not resolved.
&amp;amp;m       7
&lt;/PRE&gt;
&lt;P&gt;The blanks between the letter m and the numeric value in &amp;amp;n are clearly visible.&lt;/P&gt;
&lt;P&gt;Note that it is usually simpler to create dynamic code off a dataset than off a bunch of macro variables.&lt;/P&gt;</description>
      <pubDate>Thu, 23 Aug 2018 07:39:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/series-of-YYMM-in-end-of-quarters-between-start-to-end/m-p/489148#M127634</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-08-23T07:39:29Z</dc:date>
    </item>
  </channel>
</rss>

