<?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: macro variable resolves in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/macro-variable-resolves/m-p/505598#M135417</link>
    <description>&lt;P&gt;Set N to equal as many months back as you need to go.&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 18 Oct 2018 14:56:29 GMT</pubDate>
    <dc:creator>cousineddie</dc:creator>
    <dc:date>2018-10-18T14:56:29Z</dc:date>
    <item>
      <title>macro variable resolves</title>
      <link>https://communities.sas.com/t5/SAS-Programming/macro-variable-resolves/m-p/505575#M135405</link>
      <description>&lt;P&gt;Hi ,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can any one help me&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;i have a macro&amp;nbsp;&lt;/P&gt;&lt;P&gt;%apps(month);&lt;/P&gt;&lt;P&gt;/*month format is yymmn6.*/;&lt;/P&gt;&lt;P&gt;...&lt;/P&gt;&lt;P&gt;...&lt;/P&gt;&lt;P&gt;..&lt;/P&gt;&lt;P&gt;%mend apps;&lt;/P&gt;&lt;P&gt;%apps(201301);&lt;/P&gt;&lt;P&gt;%apps(201302);&lt;/P&gt;&lt;P&gt;%apps(201303);&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;%apps(201304);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;%apps(201305);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;%apps(201306);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;%apps(201307);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;%apps(201308);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;%apps(201309);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;%apps(201310);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;%apps(201311);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;%apps(201312);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;%apps(201401);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;till today;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;till now i am giving manual dates&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;now i have to do dynamically&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;when i pass macro in the month parameter then it has to create a dataset for each yearmonth till today&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 18 Oct 2018 14:24:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/macro-variable-resolves/m-p/505575#M135405</guid>
      <dc:creator>SRINIVAS_N</dc:creator>
      <dc:date>2018-10-18T14:24:19Z</dc:date>
    </item>
    <item>
      <title>Re: macro variable resolves</title>
      <link>https://communities.sas.com/t5/SAS-Programming/macro-variable-resolves/m-p/505583#M135411</link>
      <description>&lt;P&gt;So what is the question?&amp;nbsp;&amp;nbsp;Maybe something like:&lt;/P&gt;
&lt;PRE&gt;%macro apps (month);   /*  note the name is inconsistent as its not a month */
  data _null_;
    do year=input(substr("&amp;amp;month.",1,4),best.) to year(today);
      do month=input(substr("&amp;amp;month.",5,2),best.) to 12;
        call execute(cats('data want',put(year,z4.),put(month,z2.),'; set have; run;'));
      end;
    end;
  run;
%mend apps;

%apps(201301);&lt;/PRE&gt;
&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 18 Oct 2018 14:35:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/macro-variable-resolves/m-p/505583#M135411</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2018-10-18T14:35:28Z</dc:date>
    </item>
    <item>
      <title>Re: macro variable resolves</title>
      <link>https://communities.sas.com/t5/SAS-Programming/macro-variable-resolves/m-p/505593#M135416</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro multiple_runs(N=,interval=,dateformat=);
 %do j=0 %to &amp;amp;N. %by 1;
  %let datestring&amp;amp;j. = %sysfunc(putn(%sysfunc(intnx(&amp;amp;interval,%sysfunc(today()),-&amp;amp;j.,beg)),&amp;amp;dateformat));
  %apps(&amp;amp;&amp;amp;datestring&amp;amp;j.);
 %end;
%mend;

/* Loops through the current month (datestr0) and 4 previous months. */
%multiple_runs(N=4,interval=month,dateformat=yymmn6.);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 18 Oct 2018 14:51:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/macro-variable-resolves/m-p/505593#M135416</guid>
      <dc:creator>cousineddie</dc:creator>
      <dc:date>2018-10-18T14:51:14Z</dc:date>
    </item>
    <item>
      <title>Re: macro variable resolves</title>
      <link>https://communities.sas.com/t5/SAS-Programming/macro-variable-resolves/m-p/505598#M135417</link>
      <description>&lt;P&gt;Set N to equal as many months back as you need to go.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 18 Oct 2018 14:56:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/macro-variable-resolves/m-p/505598#M135417</guid>
      <dc:creator>cousineddie</dc:creator>
      <dc:date>2018-10-18T14:56:29Z</dc:date>
    </item>
    <item>
      <title>Re: macro variable resolves</title>
      <link>https://communities.sas.com/t5/SAS-Programming/macro-variable-resolves/m-p/505622#M135428</link>
      <description>&lt;P&gt;Note there is no need for PUTN as %SYSFUNC() already accepts a format specification.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%sysfunc(intnx(&amp;amp;interval,%sysfunc(today()),-&amp;amp;j.,beg),&amp;amp;dateformat)&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 18 Oct 2018 15:55:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/macro-variable-resolves/m-p/505622#M135428</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2018-10-18T15:55:42Z</dc:date>
    </item>
    <item>
      <title>Re: macro variable resolves</title>
      <link>https://communities.sas.com/t5/SAS-Programming/macro-variable-resolves/m-p/505643#M135438</link>
      <description>&lt;P&gt;Instead of several macro call you can change your %apps() macro code to loop through years if that possible. If not find the below code that might work.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro loop_years(yyyymm=);

%do i=%substr(&amp;amp;yyyymm,1,4) %to %sysfunc(year(%sysfunc(today())));
	%do 	j=%sysfunc(ifc(&amp;amp;i=%substr(&amp;amp;yyyymm,1,4),%substr(&amp;amp;yyyymm,5,2),01)) 
		%to   %sysfunc(ifc(&amp;amp;i=%sysfunc(year(%sysfunc(today()))),%sysfunc(month(%sysfunc(today()))),12));
%let month_j=%sysfunc(putn(&amp;amp;j,z2.));
%apps(&amp;amp;i&amp;amp;month_j);
	%end;
%end;
%mend loop_years;

%loop_years(yyyymm=201305);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 18 Oct 2018 16:23:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/macro-variable-resolves/m-p/505643#M135438</guid>
      <dc:creator>SuryaKiran</dc:creator>
      <dc:date>2018-10-18T16:23:26Z</dc:date>
    </item>
  </channel>
</rss>

