<?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: Create a macro variable with multiple variables in it in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Create-a-macro-variable-with-multiple-variables-in-it/m-p/90104#M19123</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Yes. If you want to do something similar to Art's example, you could put all your interested variables in one let statement:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%let vars=height weight;&lt;/P&gt;&lt;P&gt;proc sort data=sashelp.class out=want;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; by &amp;amp;vars.;&lt;/P&gt;&lt;P&gt;&amp;nbsp; run;&lt;/P&gt;&lt;P&gt;&amp;nbsp; proc print data=want;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; var &amp;amp;vars.;&lt;/P&gt;&lt;P&gt;&amp;nbsp; run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 10 Aug 2012 15:38:56 GMT</pubDate>
    <dc:creator>Linlin</dc:creator>
    <dc:date>2012-08-10T15:38:56Z</dc:date>
    <item>
      <title>Create a macro variable with multiple variables in it</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-a-macro-variable-with-multiple-variables-in-it/m-p/90100#M19119</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I am trying to create a macro variable that will contain multiple variables in it.&lt;/P&gt;&lt;P&gt;I thought a macro array may be the answer but am not finding any documentation that seems to use a macro array in this way (unless I am misinterpreting the white papers I have been reading).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here is a more detailed description of what I am trying to do.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1) I load a dataset in sas with multiple variables in it.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;2) I am running multiple procselect statements to generate databases of randomly selected cases that meet a given set of criteria.&amp;nbsp; This set of criteria is defined by the variables in the dataset.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;3) I am then running multiple logistic regression models using a different set of variables from the same dataset,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Because I am running multiple models using different variables in the proc select and the logistic regression I am having to change the by and var statements for the different procedures multiples times.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am hoping I can set up a macro global variable (like the macro Let command) where I define all the variables (in one global variable) for a specific procedure at the beginning of the code and then just call that macro in all the proc select and logistic regression procedures.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you for the help.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Cheers,&lt;/P&gt;&lt;P&gt;Scott&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 Aug 2012 15:15:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-a-macro-variable-with-multiple-variables-in-it/m-p/90100#M19119</guid>
      <dc:creator>sbennet</dc:creator>
      <dc:date>2012-08-10T15:15:03Z</dc:date>
    </item>
    <item>
      <title>Re: Create a macro variable with multiple variables in it</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-a-macro-variable-with-multiple-variables-in-it/m-p/90101#M19120</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;%let yourvariable=var1 var2 var3;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 Aug 2012 15:19:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-a-macro-variable-with-multiple-variables-in-it/m-p/90101#M19120</guid>
      <dc:creator>Linlin</dc:creator>
      <dc:date>2012-08-10T15:19:23Z</dc:date>
    </item>
    <item>
      <title>Re: Create a macro variable with multiple variables in it</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-a-macro-variable-with-multiple-variables-in-it/m-p/90102#M19121</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Is it really that simple?&lt;/P&gt;&lt;P&gt;I didn't try that because in the %let help online help, it said you can only assign one value to a variable assigned by %let.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Cheers,&lt;/P&gt;&lt;P&gt;Scott&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 Aug 2012 15:20:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-a-macro-variable-with-multiple-variables-in-it/m-p/90102#M19121</guid>
      <dc:creator>sbennet</dc:creator>
      <dc:date>2012-08-10T15:20:55Z</dc:date>
    </item>
    <item>
      <title>Re: Create a macro variable with multiple variables in it</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-a-macro-variable-with-multiple-variables-in-it/m-p/90103#M19122</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;In response to your question, yes it can be that simple.&amp;nbsp; The one value you are assigning happens to be a string that contains a list of variables.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;However, given your description, I would use a macro rather than just a macro variable, passing your variables in the macro call.&amp;nbsp; e.g.,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%macro runit(vars);&lt;/P&gt;&lt;P&gt;&amp;nbsp; proc sort data=sashelp.class out=want;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; by &amp;amp;vars.;&lt;/P&gt;&lt;P&gt;&amp;nbsp; run;&lt;/P&gt;&lt;P&gt;&amp;nbsp; proc print data=want;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; var &amp;amp;vars.;&lt;/P&gt;&lt;P&gt;&amp;nbsp; run;&lt;/P&gt;&lt;P&gt;&amp;nbsp; proc means data=want;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; var &amp;amp;vars.;&lt;/P&gt;&lt;P&gt;&amp;nbsp; run;&lt;/P&gt;&lt;P&gt;%mend;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%runit(height weight)&lt;/P&gt;&lt;P&gt;%runit(age weight)&lt;/P&gt;&lt;P&gt;%runit(age height weight)&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 Aug 2012 15:30:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-a-macro-variable-with-multiple-variables-in-it/m-p/90103#M19122</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2012-08-10T15:30:44Z</dc:date>
    </item>
    <item>
      <title>Re: Create a macro variable with multiple variables in it</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-a-macro-variable-with-multiple-variables-in-it/m-p/90104#M19123</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Yes. If you want to do something similar to Art's example, you could put all your interested variables in one let statement:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%let vars=height weight;&lt;/P&gt;&lt;P&gt;proc sort data=sashelp.class out=want;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; by &amp;amp;vars.;&lt;/P&gt;&lt;P&gt;&amp;nbsp; run;&lt;/P&gt;&lt;P&gt;&amp;nbsp; proc print data=want;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; var &amp;amp;vars.;&lt;/P&gt;&lt;P&gt;&amp;nbsp; run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 Aug 2012 15:38:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-a-macro-variable-with-multiple-variables-in-it/m-p/90104#M19123</guid>
      <dc:creator>Linlin</dc:creator>
      <dc:date>2012-08-10T15:38:56Z</dc:date>
    </item>
    <item>
      <title>Re: Create a macro variable with multiple variables in it</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-a-macro-variable-with-multiple-variables-in-it/m-p/90105#M19124</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you for the help!&lt;/P&gt;&lt;P&gt;That would totally work.&lt;/P&gt;&lt;P&gt;I have to run multiple macros with similar variables so to make one variable statement that I can call for each of the different macro loops would work best for my current project.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 Aug 2012 15:42:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-a-macro-variable-with-multiple-variables-in-it/m-p/90105#M19124</guid>
      <dc:creator>sbennet</dc:creator>
      <dc:date>2012-08-10T15:42:10Z</dc:date>
    </item>
    <item>
      <title>Re: Create a macro variable with multiple variables in it</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-a-macro-variable-with-multiple-variables-in-it/m-p/90106#M19125</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you for the help!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 Aug 2012 15:42:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-a-macro-variable-with-multiple-variables-in-it/m-p/90106#M19125</guid>
      <dc:creator>sbennet</dc:creator>
      <dc:date>2012-08-10T15:42:35Z</dc:date>
    </item>
    <item>
      <title>Re: Create a macro variable with multiple variables in it</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-a-macro-variable-with-multiple-variables-in-it/m-p/90107#M19126</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I guess you found a simpler solution and you should stick to that.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But Macro Arrays are really just a designation, you can achieve that easily using a correct naming.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;* one dim macro array, same thing for n dim macro array, just separate the dims with _;&lt;/P&gt;&lt;P&gt;%let X_0=2; * store here the max dim of the array;&lt;/P&gt;&lt;P&gt;%let X_1=HEIGHT; * cell 1;&lt;/P&gt;&lt;P&gt;%let X_2=WEIGHT; * cell 2;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;then traversing the array is just a matter of using the right %do cycle:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%macro runit(MVAR_ARRAY);&lt;/P&gt;&lt;P&gt;proc sort data=sashelp.class out=want;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; by %do _IDX=1 %to &amp;amp;&amp;amp;&amp;amp;MVAR_ARRAY._0;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;amp;&amp;amp;&amp;amp;MVAR_ARRAY._&amp;amp;_IDX&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; %end;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ;&lt;/P&gt;&lt;P&gt;&amp;nbsp; run;&lt;/P&gt;&lt;P&gt;&amp;nbsp; proc print data=want;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; var %do _IDX=1 %to &amp;amp;&amp;amp;&amp;amp;MVAR_ARRAY._0;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;amp;&amp;amp;&amp;amp;MVAR_ARRAY._&amp;amp;_IDX&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; %end;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ;&lt;/P&gt;&lt;P&gt;&amp;nbsp; run;&lt;/P&gt;&lt;P&gt;%mend runit;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%runit(X);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Cheers from Portugal.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 Aug 2012 16:57:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-a-macro-variable-with-multiple-variables-in-it/m-p/90107#M19126</guid>
      <dc:creator>DanielSantos</dc:creator>
      <dc:date>2012-08-10T16:57:26Z</dc:date>
    </item>
  </channel>
</rss>

