<?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 Run macro on multiple VARS in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Run-macro-on-multiple-VARS/m-p/974979#M377994</link>
    <description>&lt;P&gt;Hello&lt;/P&gt;
&lt;P&gt;Lets say I have list of variables names&amp;nbsp; in a macro variable separated&amp;nbsp; by '+'.&lt;/P&gt;
&lt;P&gt;Lets say that I want to run macro that run on each of the variables.&lt;/P&gt;
&lt;P&gt;What is the way to do it&amp;nbsp; please via code that do it automatically?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let numeric_Vars=
a_Shir_SmlHov_Pigur+
a_Shir_AKM_HZRHIUV+
a_Shir_Vetek_age_Balut+
a_CDO_ExCC_mx_pos_prob
;


/**Want to run this***/
%inf_value(ttt,information_value,a_Shir_SmlHov_Pigur,Ind_Failure);
%inf_value(ttt,information_value,a_Shir_AKM_HZRHIUV,Ind_Failure);
%inf_value(ttt,information_value,a_Shir_Vetek_age_Balut,Ind_Failure);
%inf_value(ttt,information_value,a_CDO_ExCC_mx_pos_prob ,Ind_Failure);

&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Sat, 13 Sep 2025 05:46:58 GMT</pubDate>
    <dc:creator>Ronein</dc:creator>
    <dc:date>2025-09-13T05:46:58Z</dc:date>
    <item>
      <title>Run macro on multiple VARS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Run-macro-on-multiple-VARS/m-p/974979#M377994</link>
      <description>&lt;P&gt;Hello&lt;/P&gt;
&lt;P&gt;Lets say I have list of variables names&amp;nbsp; in a macro variable separated&amp;nbsp; by '+'.&lt;/P&gt;
&lt;P&gt;Lets say that I want to run macro that run on each of the variables.&lt;/P&gt;
&lt;P&gt;What is the way to do it&amp;nbsp; please via code that do it automatically?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let numeric_Vars=
a_Shir_SmlHov_Pigur+
a_Shir_AKM_HZRHIUV+
a_Shir_Vetek_age_Balut+
a_CDO_ExCC_mx_pos_prob
;


/**Want to run this***/
%inf_value(ttt,information_value,a_Shir_SmlHov_Pigur,Ind_Failure);
%inf_value(ttt,information_value,a_Shir_AKM_HZRHIUV,Ind_Failure);
%inf_value(ttt,information_value,a_Shir_Vetek_age_Balut,Ind_Failure);
%inf_value(ttt,information_value,a_CDO_ExCC_mx_pos_prob ,Ind_Failure);

&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 13 Sep 2025 05:46:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Run-macro-on-multiple-VARS/m-p/974979#M377994</guid>
      <dc:creator>Ronein</dc:creator>
      <dc:date>2025-09-13T05:46:58Z</dc:date>
    </item>
    <item>
      <title>Re: Run macro on multiple VARS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Run-macro-on-multiple-VARS/m-p/974982#M377996</link>
      <description>&lt;P&gt;In a DATA step, run a DO loop over the string containing the macro value (use COUNTW to detrrmine the number of iterations). Use SCAN to extract the single variable names.&lt;/P&gt;
&lt;P&gt;Either use CALL EXECUTE to call the macro, or write the code to a temporary file for a later %INCLUDE.&lt;/P&gt;</description>
      <pubDate>Sat, 13 Sep 2025 06:39:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Run-macro-on-multiple-VARS/m-p/974982#M377996</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2025-09-13T06:39:04Z</dc:date>
    </item>
    <item>
      <title>Re: Run macro on multiple VARS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Run-macro-on-multiple-VARS/m-p/974997#M378002</link>
      <description>&lt;P&gt;You need make a macro to repeat&amp;nbsp;%inf_value() .&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;%macro inf_value(ttt,information_value,numeric_Vars,Ind_Failure);
%put &amp;amp;numeric_Vars.;
%mend;





%let numeric_Vars=
a_Shir_SmlHov_Pigur+
a_Shir_AKM_HZRHIUV+
a_Shir_Vetek_age_Balut+
a_CDO_ExCC_mx_pos_prob
;

%macro repeat(let);
%do i=1 %to %sysfunc(countw(&amp;amp;let.,+));
%let temp=%scan(&amp;amp;let.,&amp;amp;i,+);
%inf_value(ttt,information_value,&amp;amp;temp.,Ind_Failure);
%end;
%mend;
%repeat(&amp;amp;numeric_Vars.)
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 14 Sep 2025 06:43:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Run-macro-on-multiple-VARS/m-p/974997#M378002</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2025-09-14T06:43:55Z</dc:date>
    </item>
    <item>
      <title>Re: Run macro on multiple VARS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Run-macro-on-multiple-VARS/m-p/975037#M378030</link>
      <description>&lt;P&gt;You could use one of the methods you just learned for parsing the macro variable.&lt;/P&gt;
&lt;P&gt;A data step for example:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
  do i=1 to to countw("&amp;amp;numeric_Vars",'+');
    call execute('%nrstr(%inf_value)(ttt,information_value,'
      ||scan("&amp;amp;numeric_vars",i,'+')
      ||',Ind_Failure)'
    );
&amp;nbsp;&amp;nbsp;end;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;But perhaps the code that macro is generating using that third positional parameter is something that can accept multiple variables?&amp;nbsp; For example if the macro definition as something like:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro inf_value
(parm1 /* ttt */
,parm2 /* information_value */
,parm3 /* numeric variable */
,parm4 /* Ind_Failure */
);
proc reg dataset=analysis_set_&amp;amp;parm1 ;
   where group ="&amp;amp;parm2";
   model &amp;amp;parm4 = &amp;amp;parm3 ;
run;
%mend inf_value;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Then you could call with something like:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%inf_value(ttt,information_value
,a_Shir_SmlHov_Pigur
 a_Shir_AKM_HZRHIUV
 a_Shir_Vetek_age_Balut
 a_CDO_ExCC_mx_pos_prob
,Ind_Failure);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;And it might make sense.&lt;/P&gt;
&lt;P&gt;In that case it would be better to use space instead of + as the delimiter between the variable names.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If not you could possible modify the macro to add a %DO loop to loop over the list of values.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro inf_value(parm1,parm2,parm3_list,parm4);
%local i parm3 ;
%do i=1 %to %sysfunc(countw(&amp;amp;parm3_list,+));
  %let parm3=%scan(&amp;amp;parm3_list,&amp;amp;i,+);
/* body of the original macro */
%end;
%mend inf_value;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;In which case you could call it with your list substituted into the third positional parameter.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%inf_value(ttt,information_value,&amp;amp;numeric_vars,Ind_Failure);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And if you cannot modify the macro then make a new macro so you can have it run the %DO loop and generate the calls to the original macro.&lt;/P&gt;</description>
      <pubDate>Sun, 14 Sep 2025 20:19:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Run-macro-on-multiple-VARS/m-p/975037#M378030</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2025-09-14T20:19:42Z</dc:date>
    </item>
    <item>
      <title>Re: Run macro on multiple VARS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Run-macro-on-multiple-VARS/m-p/975051#M378034</link>
      <description>&lt;P&gt;Use the &lt;A href="https://github.com/SASPAC/macroarray" target="_self"&gt;MacroArray&lt;/A&gt; package.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;1) &lt;A href="https://github.com/SASPAC/macroarray/blob/main/macroarray.md" target="_self"&gt;Documentation&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;2) &lt;A href="https://www.lexjansen.com/wuss/2024/124_FINAL_paper_pdf.pdf" target="_self"&gt;Article&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro inf_value(ttt,information_value,numeric_Vars,Ind_Failure);
%put [&amp;amp;sysmacroname.] &amp;amp;numeric_Vars.;
data _null_;
  &amp;amp;numeric_Vars.=42;
  put _all_;
run;
%mend;




%loadPackage(macroArray)

/* macroarray */
%array(varsList[*] a_Shir_SmlHov_Pigur a_Shir_AKM_HZRHIUV a_Shir_Vetek_age_Balut a_CDO_ExCC_mx_pos_prob
,vnames=Y
,macarray=Y)

/* loop over macroarray calling %inf_value() macro */
%do_over(varsList,phrase=%nrstr(
  %inf_value(ttt,information_value,%varsList(&amp;amp;_i_.),Ind_Failure);  
))

/* clean up after using macroarray */
%deleteMacArray(varsList,macarray=Y)&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Bart&lt;/P&gt;</description>
      <pubDate>Mon, 15 Sep 2025 07:51:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Run-macro-on-multiple-VARS/m-p/975051#M378034</guid>
      <dc:creator>yabwon</dc:creator>
      <dc:date>2025-09-15T07:51:38Z</dc:date>
    </item>
  </channel>
</rss>

