<?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 loop over variables for a proc reg in SAS Forecasting and Econometrics</title>
    <link>https://communities.sas.com/t5/SAS-Forecasting-and-Econometrics/How-to-loop-over-variables-for-a-proc-reg/m-p/338341#M2180</link>
    <description>&lt;P&gt;Ok, I should explain the header better.&lt;/P&gt;
&lt;P&gt;Let's say I have a data set like this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;PERMNO &amp;nbsp; &amp;nbsp;DATE &amp;nbsp; &amp;nbsp;Y &amp;nbsp; &amp;nbsp; X1 &amp;nbsp; &amp;nbsp; X2 &amp;nbsp; &amp;nbsp; &amp;nbsp;X3&lt;/P&gt;
&lt;P&gt;A &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 100 &amp;nbsp; &amp;nbsp; xx &amp;nbsp; &amp;nbsp;xx &amp;nbsp; &amp;nbsp; &amp;nbsp;xx &amp;nbsp; &amp;nbsp; &amp;nbsp;xx&lt;/P&gt;
&lt;P&gt;A &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 100 &amp;nbsp; &amp;nbsp; xx &amp;nbsp; &amp;nbsp;xx &amp;nbsp; &amp;nbsp; &amp;nbsp;xx &amp;nbsp; &amp;nbsp; &amp;nbsp;xx&lt;/P&gt;
&lt;P&gt;A &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 100 &amp;nbsp; &amp;nbsp; xx &amp;nbsp; &amp;nbsp;xx &amp;nbsp; &amp;nbsp; &amp;nbsp;xx &amp;nbsp; &amp;nbsp; &amp;nbsp;xx&lt;/P&gt;
&lt;P&gt;B &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ......&lt;/P&gt;
&lt;P&gt;B&lt;/P&gt;
&lt;P&gt;B&lt;/P&gt;
&lt;P&gt;C&lt;/P&gt;
&lt;P&gt;C&lt;/P&gt;
&lt;P&gt;C&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Basically, I want &amp;nbsp;to run multiple regression models.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For example, Y ~ x1. Y~ x2, Y~X3, ...&lt;/P&gt;
&lt;P&gt;In my real data set there are more than 10 variables.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I know that for a single model, I can run something like this:&lt;/P&gt;
&lt;PRE&gt;proc reg data = have out = want;
    by permno date;
    model y = x1;
run;
&lt;/PRE&gt;
&lt;P&gt;But what shoud I do if I want to do a loop through my variables, so that I get all of models, y ~ x1, y~x2, y~x3 in one table. Can it possibly done in one proc reg, or should I define multiple ones and append them together?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I appreciate any help.&lt;/P&gt;
&lt;P&gt;Thanks!&lt;/P&gt;</description>
    <pubDate>Mon, 06 Mar 2017 03:22:41 GMT</pubDate>
    <dc:creator>Shayan2012</dc:creator>
    <dc:date>2017-03-06T03:22:41Z</dc:date>
    <item>
      <title>How to loop over variables for a proc reg</title>
      <link>https://communities.sas.com/t5/SAS-Forecasting-and-Econometrics/How-to-loop-over-variables-for-a-proc-reg/m-p/338341#M2180</link>
      <description>&lt;P&gt;Ok, I should explain the header better.&lt;/P&gt;
&lt;P&gt;Let's say I have a data set like this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;PERMNO &amp;nbsp; &amp;nbsp;DATE &amp;nbsp; &amp;nbsp;Y &amp;nbsp; &amp;nbsp; X1 &amp;nbsp; &amp;nbsp; X2 &amp;nbsp; &amp;nbsp; &amp;nbsp;X3&lt;/P&gt;
&lt;P&gt;A &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 100 &amp;nbsp; &amp;nbsp; xx &amp;nbsp; &amp;nbsp;xx &amp;nbsp; &amp;nbsp; &amp;nbsp;xx &amp;nbsp; &amp;nbsp; &amp;nbsp;xx&lt;/P&gt;
&lt;P&gt;A &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 100 &amp;nbsp; &amp;nbsp; xx &amp;nbsp; &amp;nbsp;xx &amp;nbsp; &amp;nbsp; &amp;nbsp;xx &amp;nbsp; &amp;nbsp; &amp;nbsp;xx&lt;/P&gt;
&lt;P&gt;A &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 100 &amp;nbsp; &amp;nbsp; xx &amp;nbsp; &amp;nbsp;xx &amp;nbsp; &amp;nbsp; &amp;nbsp;xx &amp;nbsp; &amp;nbsp; &amp;nbsp;xx&lt;/P&gt;
&lt;P&gt;B &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ......&lt;/P&gt;
&lt;P&gt;B&lt;/P&gt;
&lt;P&gt;B&lt;/P&gt;
&lt;P&gt;C&lt;/P&gt;
&lt;P&gt;C&lt;/P&gt;
&lt;P&gt;C&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Basically, I want &amp;nbsp;to run multiple regression models.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For example, Y ~ x1. Y~ x2, Y~X3, ...&lt;/P&gt;
&lt;P&gt;In my real data set there are more than 10 variables.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I know that for a single model, I can run something like this:&lt;/P&gt;
&lt;PRE&gt;proc reg data = have out = want;
    by permno date;
    model y = x1;
run;
&lt;/PRE&gt;
&lt;P&gt;But what shoud I do if I want to do a loop through my variables, so that I get all of models, y ~ x1, y~x2, y~x3 in one table. Can it possibly done in one proc reg, or should I define multiple ones and append them together?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I appreciate any help.&lt;/P&gt;
&lt;P&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Mon, 06 Mar 2017 03:22:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Forecasting-and-Econometrics/How-to-loop-over-variables-for-a-proc-reg/m-p/338341#M2180</guid>
      <dc:creator>Shayan2012</dc:creator>
      <dc:date>2017-03-06T03:22:41Z</dc:date>
    </item>
    <item>
      <title>Re: How to loop over variables for a proc reg</title>
      <link>https://communities.sas.com/t5/SAS-Forecasting-and-Econometrics/How-to-loop-over-variables-for-a-proc-reg/m-p/338348#M2181</link>
      <description>&lt;P&gt;Transform your data and use by processing. Here is an example with sashelp.class:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data longClass;
set sashelp.class;
array a{*} age height;
do i = 1 to dim(a);
    var = vname(a{i});
    value = a{i};
    output;
    end;
drop i age height;
run;

proc sort data=longClass; by sex var; run;

proc reg data=longClass plots=none;
by sex var;
model weight = value;
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 06 Mar 2017 04:15:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Forecasting-and-Econometrics/How-to-loop-over-variables-for-a-proc-reg/m-p/338348#M2181</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2017-03-06T04:15:36Z</dc:date>
    </item>
    <item>
      <title>Re: How to loop over variables for a proc reg</title>
      <link>https://communities.sas.com/t5/SAS-Forecasting-and-Econometrics/How-to-loop-over-variables-for-a-proc-reg/m-p/338814#M2188</link>
      <description>Thanks a lot, PGstats!</description>
      <pubDate>Tue, 07 Mar 2017 14:37:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Forecasting-and-Econometrics/How-to-loop-over-variables-for-a-proc-reg/m-p/338814#M2188</guid>
      <dc:creator>Shayan2012</dc:creator>
      <dc:date>2017-03-07T14:37:41Z</dc:date>
    </item>
  </channel>
</rss>

