<?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 Multiple regressions using arrays in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Multiple-regressions-using-arrays/m-p/431083#M281668</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I would like to run a number of linear univariate regressions of the form Y = aXi + e and have been trying to figure out how to use arrays for that, instead of writing out 20 regressions. I managed to create an array of independent variables in the data step, but I cannot figure out a way to access it in proc regress. There must be a simple way to do this, but having spent a day looking I haven't found it. Would be grateful if you guys could help.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you!&lt;/P&gt;</description>
    <pubDate>Thu, 25 Jan 2018 20:39:31 GMT</pubDate>
    <dc:creator>AbuYusuf</dc:creator>
    <dc:date>2018-01-25T20:39:31Z</dc:date>
    <item>
      <title>Multiple regressions using arrays</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Multiple-regressions-using-arrays/m-p/431083#M281668</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I would like to run a number of linear univariate regressions of the form Y = aXi + e and have been trying to figure out how to use arrays for that, instead of writing out 20 regressions. I managed to create an array of independent variables in the data step, but I cannot figure out a way to access it in proc regress. There must be a simple way to do this, but having spent a day looking I haven't found it. Would be grateful if you guys could help.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you!&lt;/P&gt;</description>
      <pubDate>Thu, 25 Jan 2018 20:39:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Multiple-regressions-using-arrays/m-p/431083#M281668</guid>
      <dc:creator>AbuYusuf</dc:creator>
      <dc:date>2018-01-25T20:39:31Z</dc:date>
    </item>
    <item>
      <title>Re: Multiple regressions using arrays</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Multiple-regressions-using-arrays/m-p/431085#M281669</link>
      <description>&lt;P&gt;I suspect your best approach is to Reformat your data and use a BY statement.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you want further suggestions please provide more detailed information including how your information currently looks and the type or PROC REG statements you're looking to develop.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/189251"&gt;@AbuYusuf&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I would like to run a number of linear univariate regressions of the form Y = aXi + e and have been trying to figure out how to use arrays for that, instead of writing out 20 regressions. I managed to create an array of independent variables in the data step, but I cannot figure out a way to access it in proc regress. There must be a simple way to do this, but having spent a day looking I haven't found it. Would be grateful if you guys could help.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you!&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 25 Jan 2018 20:51:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Multiple-regressions-using-arrays/m-p/431085#M281669</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-01-25T20:51:40Z</dc:date>
    </item>
    <item>
      <title>Re: Multiple regressions using arrays</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Multiple-regressions-using-arrays/m-p/431088#M281670</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/189251"&gt;@AbuYusuf&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I would like to run a number of linear univariate regressions of the form Y = aXi + e and have been trying to figure out how to use arrays for that, instead of writing out 20 regressions. I managed to create an array of independent variables in the data step, but I cannot figure out a way to access it in proc regress. There must be a simple way to do this, but having spent a day looking I haven't found it. Would be grateful if you guys could help.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you!&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc transpose name=IndVar data=sashelp.class out=class2(rename=col1=X);
   by name age;
   var height weight;
   run;
proc sort data=class2;
   by indvar;
   run;
proc reg data=class2;
   by indvar;
   model age = x;
   attrib _all_ label='';
   run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 25 Jan 2018 20:49:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Multiple-regressions-using-arrays/m-p/431088#M281670</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2018-01-25T20:49:50Z</dc:date>
    </item>
    <item>
      <title>Re: Multiple regressions using arrays</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Multiple-regressions-using-arrays/m-p/431090#M281671</link>
      <description>&lt;P&gt;Thanks a lot for the reply!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Data is&amp;nbsp;a large administrative database that has a number of diagnostic codes which I use to create a number of disease variables, say, diabetes, influenza, etc. I have cost as the dependent variable and I want to run a number of regressions where each disease is an independent variable, and adjust for a number of other factors, such as length of stay, etc. I also have age and province as categorical variables, so I run these regressions&amp;nbsp;BY age category and province.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In STATA I would have done it like this:&lt;/P&gt;&lt;P&gt;local diseases "diabetes influenza"&lt;/P&gt;&lt;P&gt;foreach a of local diseases {&lt;/P&gt;&lt;P&gt;regress cost diseases[`a']&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;That's basically it. Thank you very much for your help!&lt;/P&gt;</description>
      <pubDate>Thu, 25 Jan 2018 20:52:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Multiple-regressions-using-arrays/m-p/431090#M281671</guid>
      <dc:creator>AbuYusuf</dc:creator>
      <dc:date>2018-01-25T20:52:21Z</dc:date>
    </item>
    <item>
      <title>Re: Multiple regressions using arrays</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Multiple-regressions-using-arrays/m-p/431092#M281672</link>
      <description>&lt;P&gt;&lt;A href="https://communities.sas.com/t5/SAS-Communities-Library/How-do-I-write-a-macro-to-run-multiple-regressions/ta-p/223663" target="_blank"&gt;https://communities.sas.com/t5/SAS-Communities-Library/How-do-I-write-a-macro-to-run-multiple-regressions/ta-p/223663&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 25 Jan 2018 20:54:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Multiple-regressions-using-arrays/m-p/431092#M281672</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-01-25T20:54:06Z</dc:date>
    </item>
    <item>
      <title>Re: Multiple regressions using arrays</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Multiple-regressions-using-arrays/m-p/431097#M281673</link>
      <description>&lt;P&gt;It's a bit hard to reply without seeing the start and end points.&lt;/P&gt;
&lt;P&gt;Please provide a small example of data and the desired procedure calls.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 25 Jan 2018 21:00:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Multiple-regressions-using-arrays/m-p/431097#M281673</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2018-01-25T21:00:06Z</dc:date>
    </item>
    <item>
      <title>Re: Multiple regressions using arrays</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Multiple-regressions-using-arrays/m-p/431098#M281674</link>
      <description>&lt;P&gt;This entire thread fits under the category of:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Just because you CAN do the regressions this way, it doesn't mean you SHOULD do the regressions this way.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Instead of ordinary least squares regression, I recommend partial least squares regression (PROC PLS) which has better statistical properties (smaller root mean square error of predictions and of regression coefficients) than doing many regressions.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you want to determine which variables are important in predicting the response, and you do many regressions, you are not accounting for possible confounding of one x variable with another x variable. PLS handles this better.&lt;/P&gt;</description>
      <pubDate>Thu, 25 Jan 2018 21:00:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Multiple-regressions-using-arrays/m-p/431098#M281674</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2018-01-25T21:00:11Z</dc:date>
    </item>
    <item>
      <title>Re: Multiple regressions using arrays</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Multiple-regressions-using-arrays/m-p/431112#M281675</link>
      <description>&lt;P&gt;Use a variable list. In proc reg you may specify&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;model a -- z = myVar; &lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;to regress all variables in&amp;nbsp;your dataset variable list from a to z against myVar.&lt;/P&gt;</description>
      <pubDate>Thu, 25 Jan 2018 22:02:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Multiple-regressions-using-arrays/m-p/431112#M281675</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2018-01-25T22:02:17Z</dc:date>
    </item>
    <item>
      <title>Re: Multiple regressions using arrays</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Multiple-regressions-using-arrays/m-p/431114#M281676</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/462"&gt;@PGStats&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;Use a variable list. In proc reg you may specify&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;model a -- z = myVar; &lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;to regress all variables in&amp;nbsp;your dataset variable list from a to z against myVar.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;I thought the OP said there are many independent (X) variables. &amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 25 Jan 2018 22:05:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Multiple-regressions-using-arrays/m-p/431114#M281676</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2018-01-25T22:05:33Z</dc:date>
    </item>
    <item>
      <title>Re: Multiple regressions using arrays</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Multiple-regressions-using-arrays/m-p/431119#M281677</link>
      <description>&lt;P&gt;OOps!&lt;/P&gt;</description>
      <pubDate>Thu, 25 Jan 2018 22:29:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Multiple-regressions-using-arrays/m-p/431119#M281677</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2018-01-25T22:29:31Z</dc:date>
    </item>
    <item>
      <title>Re: Multiple regressions using arrays</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Multiple-regressions-using-arrays/m-p/431123#M281678</link>
      <description>&lt;P&gt;You can automate with &lt;STRONG&gt;call execute()&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
length reg $200;
set sashelp.cars;
array x Invoice -- length;
do i = 1 to dim(x);
    reg = cats(
        "proc reg data=sashelp.cars plots=none outest=out_",
        vname(x{i}),
        "; model MSRP=", 
        vname(x{i}),
        "; run;" );
    call execute (reg);
    end;
stop;
run;

data est_all;
set out_: ;
run;

proc print data=est_all; run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;STRONG&gt;&lt;CODE class=" language-sas"&gt;&amp;nbsp;&lt;/CODE&gt;&lt;/STRONG&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 25 Jan 2018 22:56:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Multiple-regressions-using-arrays/m-p/431123#M281678</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2018-01-25T22:56:34Z</dc:date>
    </item>
    <item>
      <title>Re: Multiple regressions using arrays</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Multiple-regressions-using-arrays/m-p/431126#M281679</link>
      <description>&lt;P&gt;Another way is to trick proc reg into testing every variable for best subset selection&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
proc reg data=sashelp.cars outest=all_est;
model MSRP = Invoice -- length / selection=RSQUARE stop=1;
run;
quit;

proc print data=all_est; run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 25 Jan 2018 23:16:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Multiple-regressions-using-arrays/m-p/431126#M281679</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2018-01-25T23:16:44Z</dc:date>
    </item>
    <item>
      <title>Re: Multiple regressions using arrays</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Multiple-regressions-using-arrays/m-p/431127#M281680</link>
      <description>&lt;P&gt;&lt;A href="https://stats.idre.ucla.edu/sas/seminars/sas-macros-introduction/" target="_blank"&gt;https://stats.idre.ucla.edu/sas/seminars/sas-macros-introduction/&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here's a full write up on macros if you choose to go down that route.&lt;/P&gt;</description>
      <pubDate>Thu, 25 Jan 2018 23:19:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Multiple-regressions-using-arrays/m-p/431127#M281680</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-01-25T23:19:05Z</dc:date>
    </item>
    <item>
      <title>Re: Multiple regressions using arrays</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Multiple-regressions-using-arrays/m-p/431829#M281681</link>
      <description>&lt;P&gt;Thank you very much! I tried the code, but my adaptation of it to my data didn't work...&lt;/P&gt;</description>
      <pubDate>Mon, 29 Jan 2018 16:05:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Multiple-regressions-using-arrays/m-p/431829#M281681</guid>
      <dc:creator>AbuYusuf</dc:creator>
      <dc:date>2018-01-29T16:05:25Z</dc:date>
    </item>
    <item>
      <title>Re: Multiple regressions using arrays</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Multiple-regressions-using-arrays/m-p/431831#M281682</link>
      <description>Thank you. I will check out proc pls.</description>
      <pubDate>Mon, 29 Jan 2018 16:06:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Multiple-regressions-using-arrays/m-p/431831#M281682</guid>
      <dc:creator>AbuYusuf</dc:creator>
      <dc:date>2018-01-29T16:06:06Z</dc:date>
    </item>
  </channel>
</rss>

