<?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: reading multiple variable with a prefix at once in a MACRO in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/reading-multiple-variable-with-a-prefix-at-once-in-a-MACRO/m-p/736480#M229430</link>
    <description>&lt;P&gt;Thank you everyone!&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 22 Apr 2021 17:40:30 GMT</pubDate>
    <dc:creator>Emma_at_SAS</dc:creator>
    <dc:date>2021-04-22T17:40:30Z</dc:date>
    <item>
      <title>reading multiple variable with a prefix at once in a MACRO</title>
      <link>https://communities.sas.com/t5/SAS-Programming/reading-multiple-variable-with-a-prefix-at-once-in-a-MACRO/m-p/736461#M229422</link>
      <description>&lt;P&gt;I wrote a macro and not I want to run it for several variables. Some variables have the same prefix for example&lt;/P&gt;
&lt;P&gt;var_name_d1&amp;nbsp;&lt;/P&gt;
&lt;P&gt;var_name_d2&amp;nbsp;&lt;/P&gt;
&lt;P&gt;var_name_d3&amp;nbsp;&lt;/P&gt;
&lt;P&gt;var_name_d4&amp;nbsp;&lt;/P&gt;
&lt;P&gt;var_name_d99&amp;nbsp;&lt;/P&gt;
&lt;P&gt;var_name_d999&lt;/P&gt;
&lt;P&gt;I am not sure if they are in the same order in the dataset or if some other column may be in between these columns.&lt;/P&gt;
&lt;P&gt;1- Can I write a short form to feed these 6 variables to my macro at one step?&lt;/P&gt;
&lt;P&gt;2- If yes, how may I do that?&lt;/P&gt;
&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Thu, 22 Apr 2021 16:59:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/reading-multiple-variable-with-a-prefix-at-once-in-a-MACRO/m-p/736461#M229422</guid>
      <dc:creator>Emma_at_SAS</dc:creator>
      <dc:date>2021-04-22T16:59:51Z</dc:date>
    </item>
    <item>
      <title>Re: reading multiple variable with a prefix at once in a MACRO</title>
      <link>https://communities.sas.com/t5/SAS-Programming/reading-multiple-variable-with-a-prefix-at-once-in-a-MACRO/m-p/736464#M229423</link>
      <description>&lt;P&gt;Without seeing the macro you wrote, it's nearly impossible to give you advice. What does the macro do?&lt;/P&gt;</description>
      <pubDate>Thu, 22 Apr 2021 17:05:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/reading-multiple-variable-with-a-prefix-at-once-in-a-MACRO/m-p/736464#M229423</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2021-04-22T17:05:06Z</dc:date>
    </item>
    <item>
      <title>Re: reading multiple variable with a prefix at once in a MACRO</title>
      <link>https://communities.sas.com/t5/SAS-Programming/reading-multiple-variable-with-a-prefix-at-once-in-a-MACRO/m-p/736467#M229424</link>
      <description>&lt;P&gt;No. The macro processor only deals with code, but the structures of datasets (and therefore the variables) become only evident when the code (created by the macro) later runs.&lt;/P&gt;
&lt;P&gt;But you can build a macro variable from dictionary.columns that contains all the variable names and can be used as a macro parameter.&lt;/P&gt;</description>
      <pubDate>Thu, 22 Apr 2021 17:08:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/reading-multiple-variable-with-a-prefix-at-once-in-a-MACRO/m-p/736467#M229424</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2021-04-22T17:08:31Z</dc:date>
    </item>
    <item>
      <title>Re: reading multiple variable with a prefix at once in a MACRO</title>
      <link>https://communities.sas.com/t5/SAS-Programming/reading-multiple-variable-with-a-prefix-at-once-in-a-MACRO/m-p/736474#M229427</link>
      <description>Look into CALL EXECUTE for ways to automate your macro call.</description>
      <pubDate>Thu, 22 Apr 2021 17:22:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/reading-multiple-variable-with-a-prefix-at-once-in-a-MACRO/m-p/736474#M229427</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2021-04-22T17:22:33Z</dc:date>
    </item>
    <item>
      <title>Re: reading multiple variable with a prefix at once in a MACRO</title>
      <link>https://communities.sas.com/t5/SAS-Programming/reading-multiple-variable-with-a-prefix-at-once-in-a-MACRO/m-p/736475#M229428</link>
      <description>&lt;P&gt;Sounds like you need to either modify your macro or create a new one to call the old one.&lt;/P&gt;
&lt;P&gt;So assume your macro calls to the old macro look like %old(dsn=sashelp.class,var=height) then your new code could look like this.&amp;nbsp; (Note the macro wrapper is not really needed).&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro new(prefix,dsname);
proc contents data=&amp;amp;dsn(keep=&amp;amp;prefix:) noprint out=names(keep=name); run;
data _null_;
  set names ;
  call execute(cats('%nrstr(%old)(dsn=',"&amp;amp;dsn",',var=',nliteral(name),')'));
run;
%mend;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 22 Apr 2021 17:24:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/reading-multiple-variable-with-a-prefix-at-once-in-a-MACRO/m-p/736475#M229428</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2021-04-22T17:24:15Z</dc:date>
    </item>
    <item>
      <title>Re: reading multiple variable with a prefix at once in a MACRO</title>
      <link>https://communities.sas.com/t5/SAS-Programming/reading-multiple-variable-with-a-prefix-at-once-in-a-MACRO/m-p/736479#M229429</link>
      <description>Thank you, PaigeMiller. Based on the next suggestions, I noticed what you mean. &lt;BR /&gt;Thanks</description>
      <pubDate>Thu, 22 Apr 2021 17:37:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/reading-multiple-variable-with-a-prefix-at-once-in-a-MACRO/m-p/736479#M229429</guid>
      <dc:creator>Emma_at_SAS</dc:creator>
      <dc:date>2021-04-22T17:37:08Z</dc:date>
    </item>
    <item>
      <title>Re: reading multiple variable with a prefix at once in a MACRO</title>
      <link>https://communities.sas.com/t5/SAS-Programming/reading-multiple-variable-with-a-prefix-at-once-in-a-MACRO/m-p/736480#M229430</link>
      <description>&lt;P&gt;Thank you everyone!&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 22 Apr 2021 17:40:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/reading-multiple-variable-with-a-prefix-at-once-in-a-MACRO/m-p/736480#M229430</guid>
      <dc:creator>Emma_at_SAS</dc:creator>
      <dc:date>2021-04-22T17:40:30Z</dc:date>
    </item>
    <item>
      <title>Re: reading multiple variable with a prefix at once in a MACRO</title>
      <link>https://communities.sas.com/t5/SAS-Programming/reading-multiple-variable-with-a-prefix-at-once-in-a-MACRO/m-p/736481#M229431</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/84351"&gt;@Emma_at_SAS&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;Thank you, PaigeMiller. Based on the next suggestions, I noticed what you mean. &lt;BR /&gt;Thanks&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Depending on what you are doing, the solution marked correct (from&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159"&gt;@Tom&lt;/a&gt;&amp;nbsp;) may be overkill. You may not need a loop or CALL EXECUTE at all, depending on what analysis you are doing with these variables.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 22 Apr 2021 17:42:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/reading-multiple-variable-with-a-prefix-at-once-in-a-MACRO/m-p/736481#M229431</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2021-04-22T17:42:46Z</dc:date>
    </item>
  </channel>
</rss>

