<?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: Weighted Least Squares across a list of variables in Statistical Procedures</title>
    <link>https://communities.sas.com/t5/Statistical-Procedures/Weighted-Least-Squares-across-a-list-of-variables/m-p/261148#M13807</link>
    <description>&lt;P&gt;Dear Reeza,&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you very much for your help. I tried to run your SAS code but the program gives me some errors:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data long2;&lt;BR /&gt;set &amp;amp;macro;&lt;BR /&gt;array var_list(*) &amp;amp;list;&lt;/P&gt;&lt;P&gt;do i = 1 to dim(macro);&lt;BR /&gt;variable = vname(var_list(i));&lt;BR /&gt;Value = var_list(i);&lt;BR /&gt;output;&lt;BR /&gt;end;&lt;/P&gt;&lt;P&gt;keep date LGD variable value ;&lt;BR /&gt;run;proc sort data=long;by variable date;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;ERROR: The DIM, LBOUND, and HBOUND functions require an array name for the first argument.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;ERROR: Variable VARIABLE not found.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I tried to modify the code:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data long;&lt;BR /&gt;set &amp;amp;macro;&lt;BR /&gt;array var_list(*) &amp;amp;list;&lt;/P&gt;&lt;P&gt;do i = 1 to dim(var_list);&lt;BR /&gt;var_list{i} = vname(var_list{i});&lt;/P&gt;&lt;P&gt;**Value{i} = var_list{i};&lt;BR /&gt;output;&lt;BR /&gt;end;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;and the output that looks like:&amp;nbsp;&lt;/P&gt;&lt;P&gt;Date &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;LGD &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; GDP &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; FE &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; i&lt;/P&gt;&lt;P&gt;. &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 50 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 0.5 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;3.1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;1&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;. &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;. &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 0.5 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;3.1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;2&amp;nbsp;&lt;/P&gt;&lt;P&gt;. &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;. &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;. &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 3.1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;3&lt;/P&gt;&lt;P&gt;. &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;. &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;. &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; . &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;4&lt;/P&gt;&lt;P&gt;. &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 30 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 2.3 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;4.5 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;1&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But I am not sure that this is what I need. Am I right? I think what I have to do is to find the way to run weighted least squares one-by-one from the list of variables. For instance, say I have LGD, GDP, FE etc., I want to run LGD = f(GDP), LGD = f(FE), LGD = f(etc.).&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am going to check another link that you sent me. Thank you very much for your help.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Yelena&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 04 Apr 2016 17:35:44 GMT</pubDate>
    <dc:creator>yelena</dc:creator>
    <dc:date>2016-04-04T17:35:44Z</dc:date>
    <item>
      <title>Weighted Least Squares across a list of variables</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Weighted-Least-Squares-across-a-list-of-variables/m-p/260853#M13794</link>
      <description>&lt;P&gt;Dear all,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you for checking my post. I need to estimate Rsquares using weighted least squares using individual regressions:&lt;/P&gt;
&lt;P&gt;LGD = alpha + beta * v(1) + epsilon&amp;nbsp;&lt;/P&gt;
&lt;P&gt;...&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;LGD = alpha + beta * v(2000) + epsilon&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I wrote the code but am not sure that the code does what I want. How can I extract one variable from &amp;amp;list (I have 2000 variables) and run WLS? Could you please help me if anyone knows how to do it.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you in advance.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let macro = ub.test;
%let list =
GDP
FE
;
proc reg data=ub.test outest=ub.est tableout;
model LGD=&amp;amp;list/selection=rsquare b;
run;
&amp;nbsp;
&amp;nbsp;
&amp;nbsp;
** run the original regression to get the residuals**;
proc reg data=ub.test;
model LGD=&amp;amp;list;
output out=ub.pred residual=residual;
run;
&amp;nbsp;
** compute the absolute and squared residuals**;
data ub.resid;
set ub.pred;
absresid=abs(residual);
sqresid=residual**2;
proc reg data=ub.resid;
&amp;nbsp;
**run a regression with the absolute residuals vs. X to get the estimated standard deviation **;
model absresid=&amp;amp;list;
output out=ub.s_weights predicted=s_hat;
&amp;nbsp;
**run a regression with the squared residuals vs. X to get the estimated standard deviation **;
model sqresid=&amp;amp;list;
output out=ub.v_weights predicted=v_hat;
run;
&amp;nbsp;
** compute the weights using the estiamted standard deviations**;
data ub.s_weights;
set ub.s_weights;
s_weight=1/(s_hat**2);
label s_weight = "weights using absolute residuals";
data ub.v_weights;
set ub.v_weights;
v_weight=1/v_hat;
label v_weight = "weights using squared residuals";
&amp;nbsp;
** do the weighted least squares using the weights from the estiamted standard deviations **;
proc reg data=ub.v_weights;
weight v_weight;
model LGD=&amp;amp;list;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 02 Apr 2016 01:08:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Weighted-Least-Squares-across-a-list-of-variables/m-p/260853#M13794</guid>
      <dc:creator>yelena</dc:creator>
      <dc:date>2016-04-02T01:08:31Z</dc:date>
    </item>
    <item>
      <title>Re: Weighted Least Squares across a list of variables</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Weighted-Least-Squares-across-a-list-of-variables/m-p/260854#M13795</link>
      <description>&lt;P&gt;Are you set on using proc reg, or can you use proc robustreg?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Otherwise you're pretty much doing what's detailed on this page:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="http://www.ats.ucla.edu/stat/sas/seminars/sas_macros_introduction/" target="_blank"&gt;http://www.ats.ucla.edu/stat/sas/seminars/sas_macros_introduction/&lt;/A&gt;&lt;/P&gt;
&lt;H4&gt;A macro program for repeating a procedure multiple times&lt;/H4&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But since you're going to be doing it multiple times I would highly suggest looking at restricting your output and how you might capture the results you need into tables. &amp;nbsp;You can look at using the &amp;nbsp;ODS SELECT statement to keep only the output you need as well as ODS OUTPUT to capture the output you need to tables. &amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;My best suggestion though would be to transpose your data to a long format. Then you can switch your code to using a BY groups method and you do one iteration. Your results will be much easier to navigate.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here's a short post that walks through it:&lt;/P&gt;
&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;
&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>Sat, 02 Apr 2016 01:07:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Weighted-Least-Squares-across-a-list-of-variables/m-p/260854#M13795</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2016-04-02T01:07:40Z</dc:date>
    </item>
    <item>
      <title>Re: Weighted Least Squares across a list of variables</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Weighted-Least-Squares-across-a-list-of-variables/m-p/260856#M13796</link>
      <description>&lt;P&gt;If you transposed your data the only change required to your code would be the BY statement in your Proc Reg's.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;To transpose you can use proc transpose or a data step. Assuming the same data from your previous question, this is an example:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data long;
set &amp;amp;merged_macro1;
array var_list(*) &amp;amp;list;

do i = 1 to dim(macro);
    variable = vname(var_list(i));
    Value = var_list(i);
    output;
end;

keep date v1 variable value ;
run;&lt;BR /&gt;&lt;BR /&gt;proc sort data=long;&lt;BR /&gt;by variable date;&lt;BR /&gt;run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Then modify your regression, the first one is illustrated below:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc reg data=long outest=ub.est tableout;
by variable;
model LGD=value/selection=rsquare b;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 02 Apr 2016 01:14:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Weighted-Least-Squares-across-a-list-of-variables/m-p/260856#M13796</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2016-04-02T01:14:29Z</dc:date>
    </item>
    <item>
      <title>Re: Weighted Least Squares across a list of variables</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Weighted-Least-Squares-across-a-list-of-variables/m-p/260860#M13797</link>
      <description>&lt;P&gt;Dear Reeza,&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you so much for helping me and sending me a preliminary code. I will try to test it and let you know if it works. Again, thank you soo much!&lt;/P&gt;&lt;P&gt;Yelena&lt;/P&gt;</description>
      <pubDate>Sat, 02 Apr 2016 01:35:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Weighted-Least-Squares-across-a-list-of-variables/m-p/260860#M13797</guid>
      <dc:creator>yelena</dc:creator>
      <dc:date>2016-04-02T01:35:20Z</dc:date>
    </item>
    <item>
      <title>Re: Weighted Least Squares across a list of variables</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Weighted-Least-Squares-across-a-list-of-variables/m-p/261148#M13807</link>
      <description>&lt;P&gt;Dear Reeza,&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you very much for your help. I tried to run your SAS code but the program gives me some errors:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data long2;&lt;BR /&gt;set &amp;amp;macro;&lt;BR /&gt;array var_list(*) &amp;amp;list;&lt;/P&gt;&lt;P&gt;do i = 1 to dim(macro);&lt;BR /&gt;variable = vname(var_list(i));&lt;BR /&gt;Value = var_list(i);&lt;BR /&gt;output;&lt;BR /&gt;end;&lt;/P&gt;&lt;P&gt;keep date LGD variable value ;&lt;BR /&gt;run;proc sort data=long;by variable date;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;ERROR: The DIM, LBOUND, and HBOUND functions require an array name for the first argument.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;ERROR: Variable VARIABLE not found.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I tried to modify the code:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data long;&lt;BR /&gt;set &amp;amp;macro;&lt;BR /&gt;array var_list(*) &amp;amp;list;&lt;/P&gt;&lt;P&gt;do i = 1 to dim(var_list);&lt;BR /&gt;var_list{i} = vname(var_list{i});&lt;/P&gt;&lt;P&gt;**Value{i} = var_list{i};&lt;BR /&gt;output;&lt;BR /&gt;end;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;and the output that looks like:&amp;nbsp;&lt;/P&gt;&lt;P&gt;Date &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;LGD &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; GDP &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; FE &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; i&lt;/P&gt;&lt;P&gt;. &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 50 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 0.5 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;3.1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;1&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;. &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;. &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 0.5 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;3.1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;2&amp;nbsp;&lt;/P&gt;&lt;P&gt;. &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;. &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;. &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 3.1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;3&lt;/P&gt;&lt;P&gt;. &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;. &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;. &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; . &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;4&lt;/P&gt;&lt;P&gt;. &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 30 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 2.3 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;4.5 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;1&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But I am not sure that this is what I need. Am I right? I think what I have to do is to find the way to run weighted least squares one-by-one from the list of variables. For instance, say I have LGD, GDP, FE etc., I want to run LGD = f(GDP), LGD = f(FE), LGD = f(etc.).&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am going to check another link that you sent me. Thank you very much for your help.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Yelena&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 04 Apr 2016 17:35:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Weighted-Least-Squares-across-a-list-of-variables/m-p/261148#M13807</guid>
      <dc:creator>yelena</dc:creator>
      <dc:date>2016-04-04T17:35:44Z</dc:date>
    </item>
    <item>
      <title>Re: Weighted Least Squares across a list of variables</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Weighted-Least-Squares-across-a-list-of-variables/m-p/261151#M13808</link>
      <description>&lt;P&gt;&lt;SPAN&gt;This line is incorrect - it should reference the array created, var_list.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;do i = 1 to dim(macro);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;So it should be:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;do i = 1 to dim(var_list);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;EDIT: &lt;/P&gt;
&lt;P&gt;You made the correction, I'm not sure why you commented out the line and removed the keep statement. Those are important. Give it a try with those included.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Yes, I understand you want to run it for every variable. So using a BY group is much more efficient.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 04 Apr 2016 17:40:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Weighted-Least-Squares-across-a-list-of-variables/m-p/261151#M13808</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2016-04-04T17:40:01Z</dc:date>
    </item>
    <item>
      <title>Re: Weighted Least Squares across a list of variables</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Weighted-Least-Squares-across-a-list-of-variables/m-p/261154#M13809</link>
      <description>&lt;P&gt;Dear Reeza,&lt;/P&gt;&lt;P&gt;I have fixed my errors:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;data&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; long2;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;set&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt; &amp;amp;macro;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;array&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt; var_list(*) &amp;amp;list;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;do&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt; i = &lt;/FONT&gt;&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;1&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/STRONG&gt; &lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;to&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt; dim(var_list);&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;variable = vname(var_list(i));&lt;/P&gt;&lt;P&gt;value = var_list(i);&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;output&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;end&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;keep&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt; date LGD variable value ;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;proc&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/STRONG&gt; &lt;STRONG&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;sort&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/STRONG&gt; &lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;data&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt;=long2;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;by&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt; variable date;&lt;/FONT&gt;&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;run&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;No more errors. It works fine. Thank you for your help!&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;I'll try to now run the second part of the code. &lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;Yelena&lt;/FONT&gt;&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>Mon, 04 Apr 2016 17:49:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Weighted-Least-Squares-across-a-list-of-variables/m-p/261154#M13809</guid>
      <dc:creator>yelena</dc:creator>
      <dc:date>2016-04-04T17:49:06Z</dc:date>
    </item>
    <item>
      <title>Re: Weighted Least Squares across a list of variables</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Weighted-Least-Squares-across-a-list-of-variables/m-p/261191#M13812</link>
      <description>&lt;P&gt;Dear Reeza,&lt;/P&gt;&lt;P&gt;Both parts of the code works. Thank you very, very much for your help.&lt;/P&gt;&lt;P&gt;I hope you have a great day!&lt;/P&gt;&lt;P&gt;Yelena&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 04 Apr 2016 18:43:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Weighted-Least-Squares-across-a-list-of-variables/m-p/261191#M13812</guid>
      <dc:creator>yelena</dc:creator>
      <dc:date>2016-04-04T18:43:54Z</dc:date>
    </item>
  </channel>
</rss>

