<?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 dynamic model code using macro? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/create-dynamic-model-code-using-macro/m-p/391881#M94210</link>
    <description>&lt;P&gt;1. Create a macro for your regression that takes a variable list&lt;/P&gt;
&lt;P&gt;2. In the data step, create a variable that has the values you need, ie&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;ID X1 X2 Variable_List&lt;/P&gt;
&lt;P&gt;1 1 1 X1 X2&lt;/P&gt;
&lt;P&gt;2 1 0 X1&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;3. Pass those to the macro using CALL EXECUTE&lt;/P&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;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 30 Aug 2017 14:58:46 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2017-08-30T14:58:46Z</dc:date>
    <item>
      <title>create dynamic model code using macro?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/create-dynamic-model-code-using-macro/m-p/391877#M94209</link>
      <description>&lt;P&gt;Let us say I have a dataset like so:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;ID X1 X2&lt;BR /&gt;1 1 1&lt;BR /&gt;2 1 0&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here Id indicates something to be modeled. The 0 and 1 in columns X1 and X2 indicate whether the indepedent varible should be used in the model (0=do not include, 1=include). So the model code to be produced would be:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;PROC GLMSELECT data=TrainingData;
model DependentVariable
= 
X1
X2
/ selection = stepwise(select=SL choose=AICC);
run;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;and&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;PROC GLMSELECT data=TrainingData;
	model DependentVariable
		= 
		X1
	/ selection = stepwise(select=SL choose=AICC);
run&lt;/PRE&gt;&lt;P&gt;respectivley. Ideally I would like to invoke a macro given the Id. The Id is then used to write and execute the modeling code. Btw the relvantTrainingData given Id can be easily initialised&amp;nbsp;from anothe dataset. Any ideas how to achieve the above? Thanks!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 30 Aug 2017 14:53:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/create-dynamic-model-code-using-macro/m-p/391877#M94209</guid>
      <dc:creator>csetzkorn</dc:creator>
      <dc:date>2017-08-30T14:53:29Z</dc:date>
    </item>
    <item>
      <title>Re: create dynamic model code using macro?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/create-dynamic-model-code-using-macro/m-p/391881#M94210</link>
      <description>&lt;P&gt;1. Create a macro for your regression that takes a variable list&lt;/P&gt;
&lt;P&gt;2. In the data step, create a variable that has the values you need, ie&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;ID X1 X2 Variable_List&lt;/P&gt;
&lt;P&gt;1 1 1 X1 X2&lt;/P&gt;
&lt;P&gt;2 1 0 X1&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;3. Pass those to the macro using CALL EXECUTE&lt;/P&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;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 30 Aug 2017 14:58:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/create-dynamic-model-code-using-macro/m-p/391881#M94210</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-08-30T14:58:46Z</dc:date>
    </item>
    <item>
      <title>Re: create dynamic model code using macro?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/create-dynamic-model-code-using-macro/m-p/391888#M94212</link>
      <description>&lt;P&gt;If you are planning to use CALL EXECUTE, you don't really need to define a macro.&amp;nbsp; Here's one way:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data _null_;&lt;/P&gt;
&lt;P&gt;set have;&lt;/P&gt;
&lt;P&gt;call execute('PROC GLMSELECT data=TrainingData;') ;&lt;/P&gt;
&lt;P&gt;call execute('model Dependentvariable =') ;&lt;/P&gt;
&lt;P&gt;array indeps {*} X1 X2 and a bunch more;&lt;/P&gt;
&lt;P&gt;do _n_=1 to dim(indeps);&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; if indeps{_n_} = 1 then do;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; varname = vname(indeps{_n_});&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; call execute(varname);&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; end;&lt;/P&gt;
&lt;P&gt;end;&lt;/P&gt;
&lt;P&gt;call execute ('/ selection = stepwise(select=SL choose=AICC); run;') ;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Obviously it's untested, so it might need to be debugged.&lt;/P&gt;</description>
      <pubDate>Wed, 30 Aug 2017 15:10:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/create-dynamic-model-code-using-macro/m-p/391888#M94212</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2017-08-30T15:10:25Z</dc:date>
    </item>
  </channel>
</rss>

