<?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 How to run models based on first N variables from a list in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-run-models-based-on-first-N-variables-from-a-list/m-p/842509#M333139</link>
    <description>&lt;P&gt;Hi,&amp;nbsp;&lt;/P&gt;&lt;P&gt;I wonder how to&amp;nbsp;run models based on first N input variables from a list. For example, the list contains "age height weight BMI income" and I would like to fit a series of regression model based on first N variable. I can write them one by one, but wonder if there is a efficient way of doing it. Thank you in advanced.&lt;/P&gt;&lt;P&gt;model 1:&lt;BR /&gt;proc reg data=data;&lt;/P&gt;&lt;P&gt;model y=age;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;model 2:&lt;BR /&gt;proc reg data=data;&lt;/P&gt;&lt;P&gt;model y=age&amp;nbsp; height;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;model 3:&lt;BR /&gt;proc reg data=data;&lt;/P&gt;&lt;P&gt;model y=age height weight;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;model 4:&lt;/P&gt;&lt;P&gt;proc reg data=data;&lt;/P&gt;&lt;P&gt;model y=age height weight BMI;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;model 5:&lt;/P&gt;&lt;P&gt;proc reg data=data;&lt;/P&gt;&lt;P&gt;model y=age height weight BMI income;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 04 Nov 2022 14:13:02 GMT</pubDate>
    <dc:creator>lionking19063</dc:creator>
    <dc:date>2022-11-04T14:13:02Z</dc:date>
    <item>
      <title>How to run models based on first N variables from a list</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-run-models-based-on-first-N-variables-from-a-list/m-p/842509#M333139</link>
      <description>&lt;P&gt;Hi,&amp;nbsp;&lt;/P&gt;&lt;P&gt;I wonder how to&amp;nbsp;run models based on first N input variables from a list. For example, the list contains "age height weight BMI income" and I would like to fit a series of regression model based on first N variable. I can write them one by one, but wonder if there is a efficient way of doing it. Thank you in advanced.&lt;/P&gt;&lt;P&gt;model 1:&lt;BR /&gt;proc reg data=data;&lt;/P&gt;&lt;P&gt;model y=age;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;model 2:&lt;BR /&gt;proc reg data=data;&lt;/P&gt;&lt;P&gt;model y=age&amp;nbsp; height;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;model 3:&lt;BR /&gt;proc reg data=data;&lt;/P&gt;&lt;P&gt;model y=age height weight;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;model 4:&lt;/P&gt;&lt;P&gt;proc reg data=data;&lt;/P&gt;&lt;P&gt;model y=age height weight BMI;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;model 5:&lt;/P&gt;&lt;P&gt;proc reg data=data;&lt;/P&gt;&lt;P&gt;model y=age height weight BMI income;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 04 Nov 2022 14:13:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-run-models-based-on-first-N-variables-from-a-list/m-p/842509#M333139</guid>
      <dc:creator>lionking19063</dc:creator>
      <dc:date>2022-11-04T14:13:02Z</dc:date>
    </item>
    <item>
      <title>Re: How to run models based on first N variables from a list</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-run-models-based-on-first-N-variables-from-a-list/m-p/842511#M333140</link>
      <description>&lt;P&gt;Where does your list reside?&lt;/P&gt;
&lt;P&gt;With Proc Reg I think you are looking at macro language. Perhaps something like:&lt;/P&gt;
&lt;PRE&gt;%macro reglist(varlist= );
   %let words=;
   proc reg data=data;

   %do i= 1 %to %sysfunc(countw(&amp;amp;varlist));
      %let words= &amp;amp;words %scan(&amp;amp;varlist,&amp;amp;i.);
      model&amp;amp;1.: model y=&amp;amp;words.;&lt;BR /&gt;      /*optional Model&amp;amp;i statements here*/
   %end;
   run;
%mend;

%reglist (varlist=age height weight BMI income);
&lt;/PRE&gt;
&lt;P&gt;Proc Reg will allow multiple model statements. If you are adding other optional statements then all of them related to a single model would have to appear before the next model statement. The bit before the model=, where I am using Model&amp;amp;i is a label that will have the text Model1, Model2, etc, depending on the number of variables used appearing in the output so you can tell which model the output is for.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 04 Nov 2022 14:47:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-run-models-based-on-first-N-variables-from-a-list/m-p/842511#M333140</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2022-11-04T14:47:25Z</dc:date>
    </item>
  </channel>
</rss>

