<?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: How do I Runn a macro program by a macro list of vars. in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-Runn-a-macro-program-by-a-macro-list-of-vars/m-p/797401#M287499</link>
    <description>&lt;P&gt;When you run the same analysis on a&amp;nbsp;&lt;EM&gt;series of variables&lt;/EM&gt;, it is usually better to transpose the variables and run everything in one step, using _NAME_ in the BY, so you process a&amp;nbsp;&lt;EM&gt;series of values&lt;/EM&gt;.&lt;/P&gt;</description>
    <pubDate>Sat, 19 Feb 2022 18:08:18 GMT</pubDate>
    <dc:creator>Kurt_Bremser</dc:creator>
    <dc:date>2022-02-19T18:08:18Z</dc:date>
    <item>
      <title>How do I Runn a macro program by a macro list of vars.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-Runn-a-macro-program-by-a-macro-list-of-vars/m-p/797376#M287479</link>
      <description>&lt;P&gt;I have a program with a macro that allows me to run the whole program for one chosen variable within the data set (i.e., %let choice=var1).&amp;nbsp; Then I run&amp;nbsp; the program where var1=1 (i.e., &amp;amp;choice=1). This allows me to create crude and age-adjusted rates, titles, and output by my age grouping for var1. I now want to run this whole program multiple times, once each for var1=1, var2=1, var3=1, .... for 17 vars. Haven't figured it out yet and would love some help.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 19 Feb 2022 11:26:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-Runn-a-macro-program-by-a-macro-list-of-vars/m-p/797376#M287479</guid>
      <dc:creator>InjuryEpi</dc:creator>
      <dc:date>2022-02-19T11:26:59Z</dc:date>
    </item>
    <item>
      <title>Re: How do I Runn a macro program by a macro list of vars.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-Runn-a-macro-program-by-a-macro-list-of-vars/m-p/797378#M287481</link>
      <description>&lt;P&gt;Without more details, I can only give you a generic outline of such a program&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro dothis;
    %let i=1 %to 17;
    %let choice=var&amp;amp;i;
    /* Run program */
%end;
%dothis&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;But (again I need more details) many analyses can be done without a macro and with one run of the program, by using multiple variables in a VAR statement, or with a BY statement, eliminating the need for macros entirely. This is preferable, in situations where it is possible to make the problem work without a macro.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So, please, don't be stingy with details. Provide more details about what you are doing, including what analyses you plan to do.&lt;/P&gt;</description>
      <pubDate>Sat, 19 Feb 2022 16:08:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-Runn-a-macro-program-by-a-macro-list-of-vars/m-p/797378#M287481</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2022-02-19T16:08:16Z</dc:date>
    </item>
    <item>
      <title>Re: How do I Runn a macro program by a macro list of vars.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-Runn-a-macro-program-by-a-macro-list-of-vars/m-p/797400#M287498</link>
      <description>&lt;P&gt;I agree with &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/10892"&gt;@PaigeMiller&lt;/a&gt; that details as to whether macro is even needed is important.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;One generic macro approach is a driver macro that calls your other macro.&lt;/P&gt;
&lt;PRE&gt;%macro driver (varlist = );
%do i  = 1 %to %sysfunc(countw( &amp;amp;varlist.));
   %let varname = %scan(&amp;amp;varlist., &amp;amp;i);
   /* this is where the call to the detail macro would go
     hopefully you provided a parameter that allows you
    to use &amp;amp;varname as the variable
  */

%end;
%mend;
/* call would have a space delimited list of variable names*/

%driver (varlist= thisvar thatvar anothervar)
&lt;/PRE&gt;
&lt;P&gt;You have not provided any details of where "choice" might come it, what the possibly ranges for each variable might be so cannot incorporate that at all.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Another approach would be to create a data set with the name of the variable and the "choice" value and use that to create calls to the macro using CALL EXECUTE in a data step using that data set.&lt;/P&gt;</description>
      <pubDate>Sat, 19 Feb 2022 18:01:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-Runn-a-macro-program-by-a-macro-list-of-vars/m-p/797400#M287498</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2022-02-19T18:01:11Z</dc:date>
    </item>
    <item>
      <title>Re: How do I Runn a macro program by a macro list of vars.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-Runn-a-macro-program-by-a-macro-list-of-vars/m-p/797401#M287499</link>
      <description>&lt;P&gt;When you run the same analysis on a&amp;nbsp;&lt;EM&gt;series of variables&lt;/EM&gt;, it is usually better to transpose the variables and run everything in one step, using _NAME_ in the BY, so you process a&amp;nbsp;&lt;EM&gt;series of values&lt;/EM&gt;.&lt;/P&gt;</description>
      <pubDate>Sat, 19 Feb 2022 18:08:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-Runn-a-macro-program-by-a-macro-list-of-vars/m-p/797401#M287499</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2022-02-19T18:08:18Z</dc:date>
    </item>
  </channel>
</rss>

