<?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 the macros automatically based on the user macro var in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/run-the-macros-automatically-based-on-the-user-macro-var/m-p/954260#M372717</link>
    <description>&lt;P&gt;Here one option.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro information_value(VAR=);
	%put Parameter Var has value &amp;amp;var;
%mend;

%let Predictor_Var_list=X R T Q V S M W;
data _null_;
	do i=1 to countw("&amp;amp;Predictor_Var_list");
		call execute(cats('%information_value(VAR=',scan("&amp;amp;Predictor_Var_list",i),');'));
	end;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Fri, 20 Dec 2024 10:25:49 GMT</pubDate>
    <dc:creator>Patrick</dc:creator>
    <dc:date>2024-12-20T10:25:49Z</dc:date>
    <item>
      <title>run the macros automatically based on the user macro var</title>
      <link>https://communities.sas.com/t5/SAS-Programming/run-the-macros-automatically-based-on-the-user-macro-var/m-p/954254#M372714</link>
      <description>&lt;P&gt;Hello&lt;/P&gt;
&lt;P&gt;Lets say that user define a macro var that contain names of fields (predictors) with comma between.&lt;/P&gt;
&lt;P&gt;Lets say that based on this macro variable should&amp;nbsp; run a macro.&lt;/P&gt;
&lt;P&gt;What is the way to run the macros automatically based on the user macro var?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let Predictor_Var_list=X R T Q V S M W;

%information_value(VAR=X);
%information_value(VAR=R);
%information_value(VAR=T);
%information_value(VAR=Q);
%information_value(VAR=V);
%information_value(VAR=S);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 20 Dec 2024 08:58:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/run-the-macros-automatically-based-on-the-user-macro-var/m-p/954254#M372714</guid>
      <dc:creator>Ronein</dc:creator>
      <dc:date>2024-12-20T08:58:10Z</dc:date>
    </item>
    <item>
      <title>Re: run the macros automatically based on the user macro var</title>
      <link>https://communities.sas.com/t5/SAS-Programming/run-the-macros-automatically-based-on-the-user-macro-var/m-p/954259#M372716</link>
      <description>&lt;P&gt;Two ways:&lt;/P&gt;
&lt;P&gt;from a DATA step:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
do i = 1 to countw("&amp;amp;predictor_var_list.");
  call execute(cats('%nrstr(%information_value(',scan("&amp;amp;predictor_var_list.",i),'))'));
end;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;from a macro:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro all;
%do i = 1 %to %sysfunc(countw(&amp;amp;predictor_var_list.));
  %let param = %scan(&amp;amp;predictor_var_list.,i.);
  %information_value(&amp;amp;param.);
%end;
%mend all;
%all&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 20 Dec 2024 10:25:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/run-the-macros-automatically-based-on-the-user-macro-var/m-p/954259#M372716</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2024-12-20T10:25:30Z</dc:date>
    </item>
    <item>
      <title>Re: run the macros automatically based on the user macro var</title>
      <link>https://communities.sas.com/t5/SAS-Programming/run-the-macros-automatically-based-on-the-user-macro-var/m-p/954260#M372717</link>
      <description>&lt;P&gt;Here one option.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro information_value(VAR=);
	%put Parameter Var has value &amp;amp;var;
%mend;

%let Predictor_Var_list=X R T Q V S M W;
data _null_;
	do i=1 to countw("&amp;amp;Predictor_Var_list");
		call execute(cats('%information_value(VAR=',scan("&amp;amp;Predictor_Var_list",i),');'));
	end;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 20 Dec 2024 10:25:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/run-the-macros-automatically-based-on-the-user-macro-var/m-p/954260#M372717</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2024-12-20T10:25:49Z</dc:date>
    </item>
    <item>
      <title>Re: run the macros automatically based on the user macro var</title>
      <link>https://communities.sas.com/t5/SAS-Programming/run-the-macros-automatically-based-on-the-user-macro-var/m-p/954278#M372721</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/11562"&gt;@Kurt_Bremser&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Two ways:&lt;/P&gt;
&lt;P&gt;from a DATA step:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
do i = 1 to countw("&amp;amp;predictor_var_list.");
  call execute(cats('%nrstr(%information_value(',scan("&amp;amp;predictor_var_list.",i),'))'));
end;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;from a macro:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro all;
%do i = 1 %to %sysfunc(countw(&amp;amp;predictor_var_list.));
  %let param = %scan(&amp;amp;predictor_var_list.,i.);
  %information_value(&amp;amp;param.);
%end;
%mend all;
%all&lt;/CODE&gt;&lt;/PRE&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Missing the &amp;amp; for I in the %scan.&amp;nbsp;&amp;nbsp; I thought I was the only one that did that....&lt;/P&gt;
&lt;P&gt;&lt;CODE class=" language-sas"&gt;  %let param = %scan(&amp;amp;predictor_var_list.,&amp;amp;i.);&lt;/CODE&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 20 Dec 2024 14:51:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/run-the-macros-automatically-based-on-the-user-macro-var/m-p/954278#M372721</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2024-12-20T14:51:04Z</dc:date>
    </item>
    <item>
      <title>Re: run the macros automatically based on the user macro var</title>
      <link>https://communities.sas.com/t5/SAS-Programming/run-the-macros-automatically-based-on-the-user-macro-var/m-p/954279#M372722</link>
      <description>&lt;P&gt;Your comment says "a macro var that contain names of fields (predictors) with comma between.". But the only place that you show a macro variable there are no commas. So which is it?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Note that in general with macro language the comma is the worst possible delimiter in macro values as they are quite likely to be interpreted as intention macro delimiters and generate errors in function or macro calls.&lt;/P&gt;
&lt;P&gt;Here is an example using &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/11562"&gt;@Kurt_Bremser&lt;/a&gt; second solution of the list without and with commas&lt;/P&gt;
&lt;PRE&gt;/* define a macro so missing macro definition isn't the error*/
%macro information_value (Var=);
   %put Parm is: &amp;amp;var;
%mend;

%let Predictor_Var_list=X R T;

%macro all;
%do i = 1 %to %sysfunc(countw(&amp;amp;predictor_var_list.));
  %let param = %scan(&amp;amp;predictor_var_list.,&amp;amp;i.);
  %information_value(var=&amp;amp;param.);
%end;
%mend all;
%all

/* with comma list*/
%let Predictor_Var_list=X,R,T;
%put Run with Predictor_Var_list= &amp;amp;Predictor_Var_list.;
%all
&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159549"&gt;@Ronein&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hello&lt;/P&gt;
&lt;P&gt;Lets say that user define a macro var that contain names of fields (predictors) with comma between.&lt;/P&gt;
&lt;P&gt;Lets say that based on this macro variable should&amp;nbsp; run a macro.&lt;/P&gt;
&lt;P&gt;What is the way to run the macros automatically based on the user macro var?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let Predictor_Var_list=X R T Q V S M W;

%information_value(VAR=X);
%information_value(VAR=R);
%information_value(VAR=T);
%information_value(VAR=Q);
%information_value(VAR=V);
%information_value(VAR=S);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 20 Dec 2024 14:53:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/run-the-macros-automatically-based-on-the-user-macro-var/m-p/954279#M372722</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2024-12-20T14:53:51Z</dc:date>
    </item>
  </channel>
</rss>

