<?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: Run multiple Macros with automatic created  dates parameters in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Run-multiple-Macros-with-automatic-created-dates-parameters/m-p/599694#M173162</link>
    <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/292395"&gt;@DaveStar&lt;/a&gt;&amp;nbsp; - Try this. Just remove the asterisk in front of "%Dave" to get your macro working:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let run_date = 28Oct2019;

data _null_;
  date = "&amp;amp;run_date"d;
  format date next_date date9.;
  do i = 0 to -5 by -1;
    next_date = intnx('MONTH', date, i, 'B'); 
    YYMM = compress(put(next_date, yymm6.),'M');
    DDMONYYYY = "'"!!put(next_date, date9.)!!"'d"; 
    call execute('*%Dave('!!YYMM!!','!!DDMONYYYY!!');');
    put _all_;
  end;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Sun, 27 Oct 2019 23:29:18 GMT</pubDate>
    <dc:creator>SASKiwi</dc:creator>
    <dc:date>2019-10-27T23:29:18Z</dc:date>
    <item>
      <title>Run multiple Macros with automatic created  dates parameters</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Run-multiple-Macros-with-automatic-created-dates-parameters/m-p/599661#M173136</link>
      <description>&lt;P&gt;Hello friends,&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="color: #333333; cursor: text; display: inline; float: none; font-size: 14px; font-style: normal; font-variant: normal; font-weight: 400; letter-spacing: normal; line-height: 1.2; orphans: 2; text-align: left; text-decoration: none; text-indent: 0px; text-transform: none; -webkit-text-stroke-width: 0px; white-space: normal; word-spacing: 0px;"&gt;&amp;nbsp;I need to run a monthly report .&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="color: #333333; cursor: text; display: inline; float: none; font-size: 14px; font-style: normal; font-variant: normal; font-weight: 400; letter-spacing: normal; line-height: 1.2; orphans: 2; text-align: left; text-decoration: none; text-indent: 0px; text-transform: none; -webkit-text-stroke-width: 0px; white-space: normal; word-spacing: 0px;"&gt;This report is using tables of last 6 months in order to create control limits.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="color: #333333; cursor: text; display: inline; float: none; font-size: 14px; font-style: normal; font-variant: normal; font-weight: 400; letter-spacing: normal; line-height: 1.2; orphans: 2; text-align: left; text-decoration: none; text-indent: 0px; text-transform: none; -webkit-text-stroke-width: 0px; white-space: normal; word-spacing: 0px;"&gt;This report code includes Macro with 2 parameters.(let's say that macro name is&amp;nbsp;Dave).&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="color: #333333; cursor: text; display: inline; float: none; font-size: 14px; font-style: normal; font-variant: normal; font-weight: 400; letter-spacing: normal; line-height: 1.2; orphans: 2; text-align: left; text-decoration: none; text-indent: 0px; text-transform: none; -webkit-text-stroke-width: 0px; white-space: normal; word-spacing: 0px;"&gt;Each month I need to run 6 macros (Then control limits will be calculated from results of these 6 macro runs)&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="color: #333333; cursor: text; display: inline; float: none; font-size: 14px; font-style: normal; font-variant: normal; font-weight: 400; letter-spacing: normal; line-height: 1.2; orphans: 2; text-align: left; text-decoration: none; text-indent: 0px; text-transform: none; -webkit-text-stroke-width: 0px; white-space: normal; word-spacing: 0px;"&gt;For example: In this month (We are in October 2019) I need to run the following macros:&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="color: #333333; cursor: text; display: inline; float: none; font-size: 14px; font-style: normal; font-variant: normal; font-weight: 400; letter-spacing: normal; line-height: 1.2; orphans: 2; text-align: left; text-decoration: none; text-indent: 0px; text-transform: none; -webkit-text-stroke-width: 0px; white-space: normal; word-spacing: 0px;"&gt;%Dave(1910,'01OCT2018'd) ;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="background-color: #ffffff; color: #333333; cursor: text; display: inline; float: none; font-size: 14px; font-style: normal; font-variant: normal; font-weight: 400; letter-spacing: normal; line-height: 1.2; orphans: 2; text-align: left; text-decoration: none; text-indent: 0px; text-transform: none; -webkit-text-stroke-width: 0px; white-space: normal; word-spacing: 0px;"&gt;%Dave(1909,'01SEP2018'd) ;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="color: #333333; cursor: text; display: inline; float: none; font-size: 14px; font-style: normal; font-variant: normal; font-weight: 400; letter-spacing: normal; line-height: 1.2; orphans: 2; text-align: left; text-decoration: none; text-indent: 0px; text-transform: none; -webkit-text-stroke-width: 0px; white-space: normal; word-spacing: 0px;"&gt;%Dave(1908,'01AUG2018'd) ;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style=" color: #333333; cursor: text; display: inline; float: none; font-size: 14px; font-style: normal; font-variant: normal; font-weight: 400; letter-spacing: normal; line-height: 1.2; orphans: 2; text-align: left; text-decoration: none; text-indent: 0px; text-transform: none; -webkit-text-stroke-width: 0px; white-space: normal; word-spacing: 0px;"&gt;%Dave(1907,'01JUL2018'd) ;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style=" color: #333333; cursor: text; display: inline; float: none; font-size: 14px; font-style: normal; font-variant: normal; font-weight: 400; letter-spacing: normal; line-height: 1.2; orphans: 2; text-align: left; text-decoration: none; text-indent: 0px; text-transform: none; -webkit-text-stroke-width: 0px; white-space: normal; word-spacing: 0px;"&gt;%Dave(1906,'01JUN2018'd) ;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="color: #333333; cursor: text; display: inline; float: none; font-size: 14px; font-style: normal; font-variant: normal; font-weight: 400; letter-spacing: normal; line-height: 1.2; orphans: 2; text-align: left; text-decoration: none; text-indent: 0px; text-transform: none; -webkit-text-stroke-width: 0px; white-space: normal; word-spacing: 0px;"&gt;%Dave(1905,'01MAY2018'd) ;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style=" color: #333333; cursor: text; display: inline; float: none; font-size: 14px; font-style: normal; font-variant: normal; font-weight: 400; letter-spacing: normal; line-height: 1.2; orphans: 2; text-align: left; text-decoration: none; text-indent: 0px; text-transform: none; -webkit-text-stroke-width: 0px; white-space: normal; word-spacing: 0px;"&gt;Next month (November 2019) I need to run the following macros:&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style=" color: #333333; cursor: text; display: inline; float: none; font-size: 14px; font-style: normal; font-variant: normal; font-weight: 400; letter-spacing: normal; line-height: 1.2; orphans: 2; text-align: left; text-decoration: none; text-indent: 0px; text-transform: none; -webkit-text-stroke-width: 0px; white-space: normal; word-spacing: 0px;"&gt;%Dave(1911,'01NOV2018'd) ;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="color: #333333; cursor: text; display: inline; float: none; font-size: 14px; font-style: normal; font-variant: normal; font-weight: 400; letter-spacing: normal; line-height: 1.2; orphans: 2; text-align: left; text-decoration: none; text-indent: 0px; text-transform: none; -webkit-text-stroke-width: 0px; white-space: normal; word-spacing: 0px;"&gt;%Dave(1910,'01OCT2018'd) ;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style=" color: #333333; cursor: text; display: inline; float: none; font-size: 14px; font-style: normal; font-variant: normal; font-weight: 400; letter-spacing: normal; line-height: 1.2; orphans: 2; text-align: left; text-decoration: none; text-indent: 0px; text-transform: none; -webkit-text-stroke-width: 0px; white-space: normal; word-spacing: 0px;"&gt;%Dave(1909,'01SEP2018'd) ;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style=" color: #333333; cursor: text; display: inline; float: none; font-size: 14px; font-style: normal; font-variant: normal; font-weight: 400; letter-spacing: normal; line-height: 1.2; orphans: 2; text-align: left; text-decoration: none; text-indent: 0px; text-transform: none; -webkit-text-stroke-width: 0px; white-space: normal; word-spacing: 0px;"&gt;%Dave(1908,'01AUG2018'd) ;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style=" color: #333333; cursor: text; display: inline; float: none; font-size: 14px; font-style: normal; font-variant: normal; font-weight: 400; letter-spacing: normal; line-height: 1.2; orphans: 2; text-align: left; text-decoration: none; text-indent: 0px; text-transform: none; -webkit-text-stroke-width: 0px; white-space: normal; word-spacing: 0px;"&gt;%Dave(1907,'01JUL2018'd) ;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="color: #333333; cursor: text; display: inline; float: none; font-size: 14px; font-style: normal; font-variant: normal; font-weight: 400; letter-spacing: normal; line-height: 1.2; orphans: 2; text-align: left; text-decoration: none; text-indent: 0px; text-transform: none; -webkit-text-stroke-width: 0px; white-space: normal; word-spacing: 0px;"&gt;%Dave(1906,'01JUN2018'd) ;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style=" color: #333333; cursor: text; display: inline; float: none; font-size: 14px; font-style: normal; font-variant: normal; font-weight: 400; letter-spacing: normal; line-height: 1.2; orphans: 2; text-align: left; text-decoration: none; text-indent: 0px; text-transform: none; -webkit-text-stroke-width: 0px; white-space: normal; word-spacing: 0px;"&gt;As you can see first parameter of macro has structure of YYMM (year of 2 digits and month of 2 digits).&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style=" color: #333333; cursor: text; display: inline; float: none; font-size: 14px; font-style: normal; font-variant: normal; font-weight: 400; letter-spacing: normal; line-height: 1.2; orphans: 2; text-align: left; text-decoration: none; text-indent: 0px; text-transform: none; -webkit-text-stroke-width: 0px; white-space: normal; word-spacing: 0px;"&gt;The reason is that each table name includes YYMM name on it.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="color: #333333; cursor: text; display: inline; float: none; font-size: 14px; font-style: normal; font-variant: normal; font-weight: 400; letter-spacing: normal; line-height: 1.2; orphans: 2; text-align: left; text-decoration: none; text-indent: 0px; text-transform: none; -webkit-text-stroke-width: 0px; white-space: normal; word-spacing: 0px;"&gt;As you can see second parameter of macro has structure of '01MonthNameYear'd (like date9. format).&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="color: #333333; cursor: text; display: inline; float: none; font-size: 14px; font-style: normal; font-variant: normal; font-weight: 400; letter-spacing: normal; line-height: 1.2; orphans: 2; text-align: left; text-decoration: none; text-indent: 0px; text-transform: none; -webkit-text-stroke-width: 0px; white-space: normal; word-spacing: 0px;"&gt;The reason is that for each customer I need to check if he/she is a new customer or not.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="color: #333333; cursor: text; display: inline; float: none; font-size: 14px; font-style: normal; font-variant: normal; font-weight: 400; letter-spacing: normal; line-height: 1.2; orphans: 2; text-align: left; text-decoration: none; text-indent: 0px; text-transform: none; -webkit-text-stroke-width: 0px; white-space: normal; word-spacing: 0px;"&gt;The criteria is to check date 1 year before YYMM&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="color: #333333; cursor: text; display: inline; float: none; font-size: 14px; font-style: normal; font-variant: normal; font-weight: 400; letter-spacing: normal; line-height: 1.2; orphans: 2; text-align: left; text-decoration: none; text-indent: 0px; text-transform: none; -webkit-text-stroke-width: 0px; white-space: normal; word-spacing: 0px;"&gt;My question:&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style=" color: #333333; cursor: text; display: inline; float: none; font-size: 14px; font-style: normal; font-variant: normal; font-weight: 400; letter-spacing: normal; line-height: 1.2; orphans: 2; text-align: left; text-decoration: none; text-indent: 0px; text-transform: none; -webkit-text-stroke-width: 0px; white-space: normal; word-spacing: 0px;"&gt;Let's say that the only user defined variable is&amp;nbsp; %let last=1910;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style=" color: #333333; cursor: text; display: inline; float: none; font-size: 14px; font-style: normal; font-variant: normal; font-weight: 400; letter-spacing: normal; line-height: 1.2; orphans: 2; text-align: left; text-decoration: none; text-indent: 0px; text-transform: none; -webkit-text-stroke-width: 0px; white-space: normal; word-spacing: 0px;"&gt;and then I need to run all automatically.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style=" color: #333333; cursor: text; display: inline; float: none; font-size: 14px; font-style: normal; font-variant: normal; font-weight: 400; letter-spacing: normal; line-height: 1.2; orphans: 2; text-align: left; text-decoration: none; text-indent: 0px; text-transform: none; -webkit-text-stroke-width: 0px; white-space: normal; word-spacing: 0px;"&gt;How can I do it please?&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style=" color: #333333; cursor: text; display: inline; float: none; font-size: 14px; font-style: normal; font-variant: normal; font-weight: 400; letter-spacing: normal; line-height: 1.2; orphans: 2; text-align: left; text-decoration: none; text-indent: 0px; text-transform: none; -webkit-text-stroke-width: 0px; white-space: normal; word-spacing: 0px;"&gt;&amp;nbsp;Thanks&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="color: #333333; cursor: text; display: inline; float: none; font-size: 14px; font-style: normal; font-variant: normal; font-weight: 400; letter-spacing: normal; line-height: 1.2; orphans: 2; text-align: left; text-decoration: none; text-indent: 0px; text-transform: none; -webkit-text-stroke-width: 0px; white-space: normal; word-spacing: 0px;"&gt;Dave&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Sun, 27 Oct 2019 17:40:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Run-multiple-Macros-with-automatic-created-dates-parameters/m-p/599661#M173136</guid>
      <dc:creator>DaveStar</dc:creator>
      <dc:date>2019-10-27T17:40:01Z</dc:date>
    </item>
    <item>
      <title>Re: Run multiple Macros with automatic created  dates parameters</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Run-multiple-Macros-with-automatic-created-dates-parameters/m-p/599664#M173139</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/292395"&gt;@DaveStar&lt;/a&gt; this is one way you could put those dates into global macros.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
	xd = today();
	date1=input(put(xd,yymmdd8.),yymmdd8.);
	 date2 = intnx('month',date1,-1,'e');
 	 date3 = intnx('month',date1,-2,'e');
 	 date4 = intnx('month',date1,-3,'e');
 	 date5 = intnx('month',date1,-4,'e');
 	 date6 = intnx('month',date1,-5,'e');
 	 date7 = intnx('month',date1,-6,'e');
	call symput('month1',put(date2,yymmn6.)); 
	call symput('month2',put(date3,yymmn6.)); 
	call symput('month3',put(date4,yymmn6.));
	call symput('month4',put(date5,yymmn6.));
	call symput('month5',put(date6,yymmn6.));
	call symput('month6',put(date7,yymmn6.));

put date1;
put date2;
put date3;
put date4;
put date5;
put date6;
put date7;
format date1 date2 date3 date4 date5 date6 date7 date9. ;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 27 Oct 2019 18:03:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Run-multiple-Macros-with-automatic-created-dates-parameters/m-p/599664#M173139</guid>
      <dc:creator>VDD</dc:creator>
      <dc:date>2019-10-27T18:03:16Z</dc:date>
    </item>
    <item>
      <title>Re: Run multiple Macros with automatic created  dates parameters</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Run-multiple-Macros-with-automatic-created-dates-parameters/m-p/599694#M173162</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/292395"&gt;@DaveStar&lt;/a&gt;&amp;nbsp; - Try this. Just remove the asterisk in front of "%Dave" to get your macro working:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let run_date = 28Oct2019;

data _null_;
  date = "&amp;amp;run_date"d;
  format date next_date date9.;
  do i = 0 to -5 by -1;
    next_date = intnx('MONTH', date, i, 'B'); 
    YYMM = compress(put(next_date, yymm6.),'M');
    DDMONYYYY = "'"!!put(next_date, date9.)!!"'d"; 
    call execute('*%Dave('!!YYMM!!','!!DDMONYYYY!!');');
    put _all_;
  end;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 27 Oct 2019 23:29:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Run-multiple-Macros-with-automatic-created-dates-parameters/m-p/599694#M173162</guid>
      <dc:creator>SASKiwi</dc:creator>
      <dc:date>2019-10-27T23:29:18Z</dc:date>
    </item>
    <item>
      <title>Re: Run multiple Macros with automatic created  dates parameters</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Run-multiple-Macros-with-automatic-created-dates-parameters/m-p/599733#M173183</link>
      <description>&lt;P&gt;Three things to add to &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13976"&gt;@SASKiwi&lt;/a&gt;'s suggestion:&lt;/P&gt;
&lt;P&gt;It is rarely (if ever) necessary to store date or datetime literals in macro variables or parameters. It is easier and simpler to use the raw values.&lt;/P&gt;
&lt;P&gt;And, if your macro contains macro code (%let, %if or %do), prevent premature execution of such statements with %nrstr.&lt;/P&gt;
&lt;P&gt;You also seem to look back one year, so I added that.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;next_date = intnx('MONTH', date, i, 'B');
prev_date = intnx('year',next_date,-1,'s');
YYMM = compress(put(next_date, yymm6.),'M');
call execute(cats('%nrstr(%Dave(',YYMM,',',prev_date,'));'));&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 28 Oct 2019 08:52:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Run-multiple-Macros-with-automatic-created-dates-parameters/m-p/599733#M173183</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2019-10-28T08:52:22Z</dc:date>
    </item>
  </channel>
</rss>

