<?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: Create macro dates in loop in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Create-macro-dates-in-loop/m-p/460400#M117016</link>
    <description>Thanks draycut. I am looking for what went wrong. Why iam getting different result.I gonna use 'mon'||put(i,z2.) in later part of my code</description>
    <pubDate>Mon, 07 May 2018 12:09:46 GMT</pubDate>
    <dc:creator>geetha1a2b3c</dc:creator>
    <dc:date>2018-05-07T12:09:46Z</dc:date>
    <item>
      <title>Create macro dates in loop</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-macro-dates-in-loop/m-p/460397#M117013</link>
      <description>&lt;P&gt;I wrote below part to get the third month from date macro.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let date=2017-01-01; 
%let a_SASdate=%sysfunc(inputn(&amp;amp;date.,yymmdd10.)) ;
%let b=%sysfunc(putn(&amp;amp;a_SASdate.,yymmn6.)) ;
%let et=%sysfunc(intnx(month,%sysfunc(inputn(&amp;amp;date.,yymmdd10.)),2,s),yymmn6.);
%put  &amp;amp;a_SASdate. &amp;amp;b. &amp;amp;et.;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;I wrote below code to create macro variable for each date.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data new;
do i=1 to 12;
call symput('mon'||put(i,z2.),put(intnx('month',&amp;amp;et.,i),yymmn6.));
a=symget('mon'||put(i,z2.));
output;
end;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Expected output&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;i   a
1   201704
2   201705
3   201706
4   201707
5   201708
6   201709
7   201710
8   201711
9   201712
10  201801
11  201801
12  201803&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;But what iam getting is&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;1   251204
2   251205
3   251206
4   251207
5   251208
6   251209
7   251210
8   251211
9   251212
10  251301
11  251302
12  251303&lt;/CODE&gt;&lt;/PRE&gt;&lt;DIV class="post-text"&gt;&lt;P&gt;What went wrong?&lt;/P&gt;&lt;/DIV&gt;</description>
      <pubDate>Mon, 07 May 2018 11:55:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-macro-dates-in-loop/m-p/460397#M117013</guid>
      <dc:creator>geetha1a2b3c</dc:creator>
      <dc:date>2018-05-07T11:55:19Z</dc:date>
    </item>
    <item>
      <title>Re: Create macro dates in loop</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-macro-dates-in-loop/m-p/460399#M117015</link>
      <description>&lt;P&gt;Not sure where your error is since I have not checked.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;However, you are overcomplicating things massively in my opinion. You can do like this to get your desired result&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data dates(keep= i a);
    date='01jan2017'd;
    monthsahead=3;
    do i=1 to 12;
        a=intnx('month', date, i+months-1, 'sameday');
        output;
    end;
    format a yymmn6.;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 07 May 2018 12:06:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-macro-dates-in-loop/m-p/460399#M117015</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2018-05-07T12:06:19Z</dc:date>
    </item>
    <item>
      <title>Re: Create macro dates in loop</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-macro-dates-in-loop/m-p/460400#M117016</link>
      <description>Thanks draycut. I am looking for what went wrong. Why iam getting different result.I gonna use 'mon'||put(i,z2.) in later part of my code</description>
      <pubDate>Mon, 07 May 2018 12:09:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-macro-dates-in-loop/m-p/460400#M117016</guid>
      <dc:creator>geetha1a2b3c</dc:creator>
      <dc:date>2018-05-07T12:09:46Z</dc:date>
    </item>
    <item>
      <title>Re: Create macro dates in loop</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-macro-dates-in-loop/m-p/460403#M117018</link>
      <description>&lt;P&gt;The data step is fine.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let et="&amp;amp;sysdate9"d ;
data new;
length i 8 a $6 ;
do i=1 to 12;
call symputX('mon'||put(i,z2.),put(intnx('month',&amp;amp;et.,i),yymmn6.));
a=symget('mon'||put(i,z2.));
output;
 put i= a= ;
end;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;But it is assuming that ET contains a date value, and it does not.&lt;/P&gt;
&lt;P&gt;Why not just store the date value into ET?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let et=%sysfunc(intnx(month,%sysfunc(inputn(&amp;amp;date.,yymmdd10.)),2,s));&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 07 May 2018 12:26:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-macro-dates-in-loop/m-p/460403#M117018</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2018-05-07T12:26:30Z</dc:date>
    </item>
    <item>
      <title>Re: Create macro dates in loop</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-macro-dates-in-loop/m-p/460409#M117021</link>
      <description>I am trying use the above resolved like&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;%let perf=12;&lt;BR /&gt;%macro addall(dname,rrun);&lt;BR /&gt;%do j=1 %to &amp;amp;rrun;&lt;BR /&gt;%let z=%sysfunc(putn,(&amp;amp;j,z2.));&lt;BR /&gt;&amp;amp;dname._&amp;amp;&amp;amp;mon.&amp;amp;z;&lt;BR /&gt;%end;&lt;BR /&gt;%mend addall;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;data new1;&lt;BR /&gt;set %addall(new,&amp;amp;perf.);&lt;BR /&gt;run;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Getting below error&lt;BR /&gt;data new1;&lt;BR /&gt;64&lt;BR /&gt;65 set %addall(new,&amp;amp;perf.);&lt;BR /&gt;ERROR: Expected open parenthesis after macro function name not found.&lt;BR /&gt;NOTE: Line generated by the macro variable "Z".&lt;BR /&gt;65 mon.(1,z2.))&lt;BR /&gt;_ _&lt;BR /&gt;22 22&lt;BR /&gt;200&lt;BR /&gt;ERROR 22-7: Invalid option name 1.&lt;BR /&gt;&lt;BR /&gt;ERROR 22-322: Syntax error, expecting one of the following: a name, a quoted string, ;, CUROBS, END, INDSNAME, KEY, KEYRESET, KEYS,&lt;BR /&gt;NOBS, OPEN, POINT, _DATA_, _LAST_, _NULL_.&lt;BR /&gt;&lt;BR /&gt;ERROR 200-322: The symbol is not recognized and will be ignored.&lt;BR /&gt;&lt;BR /&gt;NOTE: Line generated by the macro variable "Z".&lt;BR /&gt;65 new_&amp;amp;mon.&lt;BR /&gt;_&lt;BR /&gt;22&lt;BR /&gt;200&lt;BR /&gt;WARNING: Apparent symbolic reference MON not resolved.&lt;BR /&gt;ERROR: Expected open parenthesis after macro function name not found.&lt;BR /&gt;NOTE: Line generated by the macro variable "Z".&lt;BR /&gt;65 new_&amp;amp;mon.&lt;BR /&gt;____&lt;BR /&gt;180&lt;BR /&gt;WARNING: Apparent symbolic reference MON not resolved.&lt;BR /&gt;ERROR: Expected open parenthesis after macro function name not found.&lt;BR /&gt;NOTE: Line generated by the macro variable "Z".&lt;BR /&gt;65 new_&amp;amp;mon.&lt;BR /&gt;____&lt;BR /&gt;180&lt;BR /&gt;WARNING: Apparent symbolic reference MON not resolved.&lt;BR /&gt;ERROR: Expected open parenthesis after macro function name not found.&lt;BR /&gt;NOTE: Line generated by the macro variable "Z".&lt;BR /&gt;65 new_&amp;amp;mon.&lt;BR /&gt;____&lt;BR /&gt;180&lt;BR /&gt;WARNING: Apparent symbolic reference MON not resolved.&lt;BR /&gt;ERROR: Expected open parenthesis after macro function name not found.&lt;BR /&gt;NOTE: Line generated by the macro variable "Z".&lt;BR /&gt;65 new_&amp;amp;mon.&lt;BR /&gt;____&lt;BR /&gt;180&lt;BR /&gt;WARNING: Apparent symbolic reference MON not resolved.&lt;BR /&gt;ERROR: Expected open parenthesis after macro function name not found.&lt;BR /&gt;NOTE: Line generated by the macro variable "Z".&lt;BR /&gt;65 new_&amp;amp;mon.&lt;BR /&gt;____&lt;BR /&gt;180&lt;BR /&gt;WARNING: Apparent symbolic reference MON not resolved.&lt;BR /&gt;ERROR: Expected open parenthesis after macro function name not found.&lt;BR /&gt;NOTE: Line generated by the macro variable "Z".&lt;BR /&gt;65 new_&amp;amp;mon.&lt;BR /&gt;____&lt;BR /&gt;180&lt;BR /&gt;WARNING: Apparent symbolic reference MON not resolved.&lt;BR /&gt;ERROR: Expected open parenthesis after macro function name not found.&lt;BR /&gt;NOTE: Line generated by the macro variable "Z".&lt;BR /&gt;65 new_&amp;amp;mon.&lt;BR /&gt;____&lt;BR /&gt;180&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Mon, 07 May 2018 13:06:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-macro-dates-in-loop/m-p/460409#M117021</guid>
      <dc:creator>geetha1a2b3c</dc:creator>
      <dc:date>2018-05-07T13:06:03Z</dc:date>
    </item>
    <item>
      <title>Re: Create macro dates in loop</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-macro-dates-in-loop/m-p/460414#M117022</link>
      <description>&lt;P&gt;There's a comma right after putn that does not belong there.&lt;/P&gt;</description>
      <pubDate>Mon, 07 May 2018 13:38:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-macro-dates-in-loop/m-p/460414#M117022</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-05-07T13:38:41Z</dc:date>
    </item>
  </channel>
</rss>

