<?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 macro on data set values in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Run-macro-on-data-set-values/m-p/964966#M375744</link>
    <description>&lt;P&gt;The error is easy to see from the log:&lt;/P&gt;
&lt;PRE&gt;29         call execute(cats('%nrstr(Run_code'));
30         Run;

ERROR: Expected close parenthesis after macro function invocation not found.&lt;/PRE&gt;
&lt;P&gt;You do not close the %NRSTR() function call.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But what is Run_code??&amp;nbsp; That is not a valid SAS command. And it does not have either % or &amp;amp; so it has nothing to do with the macro processor either. And it is not a variable in the data step, since there are no variables in that data step.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Don't you want to run the macro RRR?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%RRR(2410)
%RRR(2411)
%RRR(2412)
%RRR(2501)
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;So just do that.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
  start='01OCT2024'd;
  end='01JAN2025'd;
  do offset=0 to intck('month',start,end);
    call execute(cats('%nrstr(%rrr)(',put(intnx('month',start,offset),yymmn4.),')'));
  end;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Example:&lt;/P&gt;
&lt;PRE&gt;1    %macro rrr / parmbuff;
2    %put Running macro call &amp;amp;sysmacroname.&amp;amp;syspbuff.;
3    %mend rrr;
4    data _null_;
5      start='01OCT2024'd;
6      end='01JAN2025'd;
7      do offset=0 to intck('month',start,end);
8        call
8  ! execute(cats('%nrstr(%rrr)(',put(intnx('month',start,offset),yymmn4.),')'
8  ! ));
9      end;
10   run;


NOTE: CALL EXECUTE generated line.
1   + %rrr(2410)
Running macro call RRR(2410)
2   + %rrr(2411)
Running macro call RRR(2411)
3   + %rrr(2412)
Running macro call RRR(2412)
4   + %rrr(2501)
Running macro call RRR(2501)
&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 23 Apr 2025 16:29:03 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2025-04-23T16:29:03Z</dc:date>
    <item>
      <title>Run macro on data set values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Run-macro-on-data-set-values/m-p/964964#M375743</link>
      <description>Hello&lt;BR /&gt;I want to run macro for different macro values that are taken from data set.&lt;BR /&gt;Way3 is not working (error)&lt;BR /&gt;what is the way to fix it please???&lt;BR /&gt;&amp;amp;nbsp;&lt;BR /&gt;&amp;amp;nbsp;&lt;BR /&gt; &lt;BR /&gt;&lt;BR /&gt;data t2410;&lt;BR /&gt;input CustID x;&lt;BR /&gt;cards;&lt;BR /&gt;1 10&lt;BR /&gt;2 20&lt;BR /&gt;;&lt;BR /&gt;Run;&lt;BR /&gt;data t2411;&lt;BR /&gt;input CustID w;&lt;BR /&gt;cards;&lt;BR /&gt;1 15&lt;BR /&gt;2 25&lt;BR /&gt;;&lt;BR /&gt;Run;&lt;BR /&gt;data t2412;&lt;BR /&gt;input CustID z;&lt;BR /&gt;cards;&lt;BR /&gt;1 30&lt;BR /&gt;2 50&lt;BR /&gt;;&lt;BR /&gt;Run;&lt;BR /&gt;data t2501;&lt;BR /&gt;input CustID y;&lt;BR /&gt;cards;&lt;BR /&gt;1 1&lt;BR /&gt;2 0&lt;BR /&gt;;&lt;BR /&gt;Run;&lt;BR /&gt;data today_tbl;&lt;BR /&gt;input CustID x_today w_today z_today y_today;&lt;BR /&gt;cards;&lt;BR /&gt;1 10 20 30 1&lt;BR /&gt;2 20 30 40 0&lt;BR /&gt;;&lt;BR /&gt;Run;&lt;BR /&gt;&lt;BR /&gt;/**Way1 to run---type manual the run code***/&lt;BR /&gt;/**Way1 to run---type manual the run code***/&lt;BR /&gt;/**Way1 to run---type manual the run code***/&lt;BR /&gt;%macro RRR(mon);&lt;BR /&gt;data want&amp;amp;amp;mon.;&lt;BR /&gt;merge t&amp;amp;amp;mon.  today_tbl;&lt;BR /&gt;by CustID;&lt;BR /&gt;Run;&lt;BR /&gt;%mend RRR;&lt;BR /&gt;%RRR(2410)&lt;BR /&gt;%RRR(2411)&lt;BR /&gt;%RRR(2412)&lt;BR /&gt;%RRR(2501)&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;/**Way2 to run***/&lt;BR /&gt;/**Way2 to run***/&lt;BR /&gt;/**Way2 to run***/&lt;BR /&gt;%let start_YYMM=2410;&lt;BR /&gt;%let end_YYMM=2501;&lt;BR /&gt;%let date_start=%sysfunc(inputn(&amp;amp;amp;start_YYMM.,yymmn4.));&lt;BR /&gt;%let date_end=%sysfunc(inputn(&amp;amp;amp;end_YYMM.,yymmn4.));&lt;BR /&gt;%let nr_months=%SYSFUNC(intck(month,&amp;amp;amp;date_start,&amp;amp;amp;date_end));&lt;BR /&gt;%put date_start=&amp;amp;amp;date_start.  ; &lt;BR /&gt;%put date_end=&amp;amp;amp;date_end. ;  &lt;BR /&gt;%put nr_months=&amp;amp;amp;nr_months. ;  &lt;BR /&gt;&lt;BR /&gt;%macro months;&lt;BR /&gt;%do j=0 %to &amp;amp;amp;nr_months;&lt;BR /&gt;YYMM=input(put(intnx('month',&amp;amp;amp;date_start.,&amp;amp;amp;j.),yymmn4.),best.);&lt;BR /&gt;output;&lt;BR /&gt;%end;&lt;BR /&gt;%mend months;&lt;BR /&gt;&lt;BR /&gt;data series_YYMM_for_macro_tbl;&lt;BR /&gt;%months;&lt;BR /&gt;run;&lt;BR /&gt;&lt;BR /&gt;proc sql;&lt;BR /&gt;create table Run_macro_code_tbl as&lt;BR /&gt;select cats('%RRR(',YYMM,')')  as Run_code&lt;BR /&gt;from series_YYMM_for_macro_tbl&lt;BR /&gt;;&lt;BR /&gt;quit;&lt;BR /&gt;&lt;BR /&gt;proc sql noprint;&lt;BR /&gt;select Run_code into :code separated by ' '&lt;BR /&gt;from Run_macro_code_tbl&lt;BR /&gt;;&lt;BR /&gt;quit;&lt;BR /&gt;&amp;amp;amp;code&lt;BR /&gt;&lt;BR /&gt;/**Way3 to run***/&lt;BR /&gt;/**Way3 to run***/&lt;BR /&gt;/**Way3 to run***/&lt;BR /&gt;options mprint;/* turn on macro debugging**/&lt;BR /&gt;&lt;BR /&gt;data _null_;&lt;BR /&gt;Set Run_macro_code_tbl;&lt;BR /&gt;call execute(cats('%nrstr(Run_code'));&lt;BR /&gt;Run;&lt;BR /&gt;&amp;amp;nbsp;&lt;BR /&gt;&amp;amp;nbsp;&lt;BR /&gt;&amp;amp;nbsp;&lt;BR /&gt;Log of way3 that have error&lt;BR /&gt;1                                                          The SAS System                            11:26 Wednesday, April 23, 2025&lt;BR /&gt;&lt;BR /&gt;1          ;*';*";*/;quit;run;&lt;BR /&gt;2          OPTIONS PAGENO=MIN;&lt;BR /&gt;3          %LET _CLIENTTASKLABEL='Program 1';&lt;BR /&gt;4          %LET _CLIENTPROCESSFLOWNAME='Standalone Not In Project';&lt;BR /&gt;5          %LET _CLIENTPROJECTPATH='';&lt;BR /&gt;6          %LET _CLIENTPROJECTPATHHOST='';&lt;BR /&gt;7          %LET _CLIENTPROJECTNAME='';&lt;BR /&gt;8          %LET _SASPROGRAMFILE='';&lt;BR /&gt;9          %LET _SASPROGRAMFILEHOST='';&lt;BR /&gt;10         &lt;BR /&gt;11         ODS _ALL_ CLOSE;&lt;BR /&gt;12         OPTIONS DEV=SVG;&lt;BR /&gt;13         GOPTIONS XPIXELS=0 YPIXELS=0;&lt;BR /&gt;14         %macro HTML5AccessibleGraphSupported;&lt;BR /&gt;15             %if %_SAS_VERCOMP_FV(9,4,4, 0,0,0) &amp;amp;gt;= 0 %then ACCESSIBLE_GRAPH;&lt;BR /&gt;16         %mend;&lt;BR /&gt;17         FILENAME EGHTML TEMP;&lt;BR /&gt;18         ODS HTML5(ID=EGHTML) FILE=EGHTML&lt;BR /&gt;19             OPTIONS(BITMAP_MODE='INLINE')&lt;BR /&gt;20             %HTML5AccessibleGraphSupported&lt;BR /&gt;NOTE: The ACCESSIBLE_GRAPH option is pre-production for this release.&lt;BR /&gt;21             ENCODING='utf-8'&lt;BR /&gt;22             STYLE=HTMLBlue&lt;BR /&gt;23             NOGTITLE&lt;BR /&gt;24             NOGFOOTNOTE&lt;BR /&gt;25             GPATH=&amp;amp;amp;sasworklocation&lt;BR /&gt;26         ;&lt;BR /&gt;NOTE: Writing HTML5(EGHTML) Body file: EGHTML&lt;BR /&gt;27         &lt;BR /&gt;28         data _null_;&lt;BR /&gt;29         call execute(cats('%nrstr(Run_code'));&lt;BR /&gt;30         Run;&lt;BR /&gt;&lt;BR /&gt;ERROR: Expected close parenthesis after macro function invocation not found.&lt;BR /&gt;NOTE: The SAS System stopped processing this step because of errors.&lt;BR /&gt;NOTE: DATA statement used (Total process time):&lt;BR /&gt;      real time           0.00 seconds&lt;BR /&gt;      user cpu time       0.00 seconds&lt;BR /&gt;      system cpu time     0.00 seconds&lt;BR /&gt;      memory              347.71k&lt;BR /&gt;      OS Memory           26524.00k&lt;BR /&gt;      Timestamp           04/23/2025 06:34:58 PM&lt;BR /&gt;      Step Count                        231  Switch Count  0&lt;BR /&gt;      Page Faults                       0&lt;BR /&gt;      Page Reclaims                     42&lt;BR /&gt;      Page Swaps                        0&lt;BR /&gt;      Voluntary Context Switches        0&lt;BR /&gt;      Involuntary Context Switches      0&lt;BR /&gt;      Block Input Operations            0&lt;BR /&gt;      Block Output Operations           0&lt;BR /&gt;      &lt;BR /&gt;&lt;BR /&gt;NOTE: CALL EXECUTE generated line.&lt;BR /&gt;1         + Run_code&lt;BR /&gt;31         &lt;BR /&gt;32         &lt;BR /&gt;33         %LET _CLIENTTASKLABEL=;&lt;BR /&gt;34         %LET _CLIENTPROCESSFLOWNAME=;&lt;BR /&gt;2                                                          The SAS System                            11:26 Wednesday, April 23, 2025&lt;BR /&gt;&lt;BR /&gt;35         %LET _CLIENTPROJECTPATH=;&lt;BR /&gt;36         %LET _CLIENTPROJECTPATHHOST=;&lt;BR /&gt;37         %LET _CLIENTPROJECTNAME=;&lt;BR /&gt;38         %LET _SASPROGRAMFILE=;&lt;BR /&gt;39         %LET _SASPROGRAMFILEHOST=;&lt;BR /&gt;40         &lt;BR /&gt;41         ;*';*";*/;quit;run;&lt;BR /&gt;NOTE: Line generated by the CALL EXECUTE routine.&lt;BR /&gt;1         + Run_code&lt;BR /&gt;            ________&lt;BR /&gt;            180&lt;BR /&gt;ERROR 180-322: Statement is not valid or it is used out of proper order.&lt;BR /&gt;&lt;BR /&gt;42         ODS _ALL_ CLOSE;&lt;BR /&gt;43         &lt;BR /&gt;44         &lt;BR /&gt;45         QUIT; RUN;&lt;BR /&gt;46</description>
      <pubDate>Wed, 23 Apr 2025 17:04:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Run-macro-on-data-set-values/m-p/964964#M375743</guid>
      <dc:creator>Ronein</dc:creator>
      <dc:date>2025-04-23T17:04:39Z</dc:date>
    </item>
    <item>
      <title>Re: Run macro on data set values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Run-macro-on-data-set-values/m-p/964966#M375744</link>
      <description>&lt;P&gt;The error is easy to see from the log:&lt;/P&gt;
&lt;PRE&gt;29         call execute(cats('%nrstr(Run_code'));
30         Run;

ERROR: Expected close parenthesis after macro function invocation not found.&lt;/PRE&gt;
&lt;P&gt;You do not close the %NRSTR() function call.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But what is Run_code??&amp;nbsp; That is not a valid SAS command. And it does not have either % or &amp;amp; so it has nothing to do with the macro processor either. And it is not a variable in the data step, since there are no variables in that data step.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Don't you want to run the macro RRR?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%RRR(2410)
%RRR(2411)
%RRR(2412)
%RRR(2501)
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;So just do that.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
  start='01OCT2024'd;
  end='01JAN2025'd;
  do offset=0 to intck('month',start,end);
    call execute(cats('%nrstr(%rrr)(',put(intnx('month',start,offset),yymmn4.),')'));
  end;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Example:&lt;/P&gt;
&lt;PRE&gt;1    %macro rrr / parmbuff;
2    %put Running macro call &amp;amp;sysmacroname.&amp;amp;syspbuff.;
3    %mend rrr;
4    data _null_;
5      start='01OCT2024'd;
6      end='01JAN2025'd;
7      do offset=0 to intck('month',start,end);
8        call
8  ! execute(cats('%nrstr(%rrr)(',put(intnx('month',start,offset),yymmn4.),')'
8  ! ));
9      end;
10   run;


NOTE: CALL EXECUTE generated line.
1   + %rrr(2410)
Running macro call RRR(2410)
2   + %rrr(2411)
Running macro call RRR(2411)
3   + %rrr(2412)
Running macro call RRR(2412)
4   + %rrr(2501)
Running macro call RRR(2501)
&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 23 Apr 2025 16:29:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Run-macro-on-data-set-values/m-p/964966#M375744</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2025-04-23T16:29:03Z</dc:date>
    </item>
  </channel>
</rss>

