<?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: Proc Reg  :  generate new variables from some coefficients in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Proc-Reg-generate-new-variables-from-some-coefficients/m-p/647484#M78614</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/313878"&gt;@Golf&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Why don't you take also estimated parameters for variables D, E and F? Is it a mistake ?&lt;/P&gt;
&lt;P&gt;As suggested by&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/10892"&gt;@PaigeMiller&lt;/a&gt;&amp;nbsp; you can retrieve the residuals in an OUTPUT statement.&lt;/P&gt;
&lt;P&gt;Maybe you will need to re-run the model with only A, B and C to get the desired calculation.&lt;/P&gt;
&lt;P&gt;NB: for information, you can gather the parameter estimates by specifying the&amp;nbsp;outest= option in the PROC REG statement.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;best,&lt;/P&gt;</description>
    <pubDate>Wed, 13 May 2020 14:47:02 GMT</pubDate>
    <dc:creator>ed_sas_member</dc:creator>
    <dc:date>2020-05-13T14:47:02Z</dc:date>
    <item>
      <title>Proc Reg  :  generate new variables from some coefficients</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Proc-Reg-generate-new-variables-from-some-coefficients/m-p/647479#M78611</link>
      <description>&lt;P&gt;Hello,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; I have 6 independent variables (A, B, C, D, E, and F)&lt;/P&gt;
&lt;P&gt;proc reg&amp;nbsp; &amp;nbsp;data = example; &lt;BR /&gt;model&amp;nbsp; y =&amp;nbsp; A B C D E F;&lt;/P&gt;
&lt;P&gt;run; &lt;/P&gt;
&lt;P&gt;Given that&amp;nbsp; b_A, b_B and b_c are coefficients of A, B and C, respectively.&lt;/P&gt;
&lt;P&gt;How can I generate a new variable from&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; NewVar = y - (b_A)*A&amp;nbsp; - (b_B)*B - (b_C)*C&lt;/P&gt;
&lt;P&gt;Thank You&lt;/P&gt;</description>
      <pubDate>Wed, 13 May 2020 14:37:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Proc-Reg-generate-new-variables-from-some-coefficients/m-p/647479#M78611</guid>
      <dc:creator>Golf</dc:creator>
      <dc:date>2020-05-13T14:37:39Z</dc:date>
    </item>
    <item>
      <title>Re: Proc Reg  :  generate new variables from some coefficients</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Proc-Reg-generate-new-variables-from-some-coefficients/m-p/647481#M78612</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/313878"&gt;@Golf&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hello,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; I have 6 independent variables (A, B, C, D, E, and F)&lt;/P&gt;
&lt;P&gt;proc reg&amp;nbsp; &amp;nbsp;data = example; &lt;BR /&gt;model&amp;nbsp; y =&amp;nbsp; A B C D E F;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;Given that&amp;nbsp; b_A, b_B and b_c are coefficients of A, B and C, respectively.&lt;/P&gt;
&lt;P&gt;How can I generate a new variable from&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; NewVar = y - (b_A)*A&amp;nbsp; - (b_B)*B - (b_C)*C&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;You want to compute residuals (y – predicted value)?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Add an OUTPUT statement into your PROC REG that asks for residuals to be computed&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc reg data = example; 
model y =&amp;nbsp; A B C D E F;
output out=residuals r=residual;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 13 May 2020 14:42:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Proc-Reg-generate-new-variables-from-some-coefficients/m-p/647481#M78612</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2020-05-13T14:42:48Z</dc:date>
    </item>
    <item>
      <title>Re: Proc Reg  :  generate new variables from some coefficients</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Proc-Reg-generate-new-variables-from-some-coefficients/m-p/647484#M78614</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/313878"&gt;@Golf&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Why don't you take also estimated parameters for variables D, E and F? Is it a mistake ?&lt;/P&gt;
&lt;P&gt;As suggested by&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/10892"&gt;@PaigeMiller&lt;/a&gt;&amp;nbsp; you can retrieve the residuals in an OUTPUT statement.&lt;/P&gt;
&lt;P&gt;Maybe you will need to re-run the model with only A, B and C to get the desired calculation.&lt;/P&gt;
&lt;P&gt;NB: for information, you can gather the parameter estimates by specifying the&amp;nbsp;outest= option in the PROC REG statement.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;best,&lt;/P&gt;</description>
      <pubDate>Wed, 13 May 2020 14:47:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Proc-Reg-generate-new-variables-from-some-coefficients/m-p/647484#M78614</guid>
      <dc:creator>ed_sas_member</dc:creator>
      <dc:date>2020-05-13T14:47:02Z</dc:date>
    </item>
    <item>
      <title>Re: Proc Reg  :  generate new variables from some coefficients</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Proc-Reg-generate-new-variables-from-some-coefficients/m-p/647487#M78615</link>
      <description>PaigeMiller,&lt;BR /&gt;   Nope.   I don't want predicted value to subtract from y.    &lt;BR /&gt;I want to use  (b_A)*A  + (b_B)*B + (b_C)*C to subtract from y  as follow:&lt;BR /&gt;NewVar = y - (b_A)*A  - (b_B)*B - (b_C)*C.</description>
      <pubDate>Wed, 13 May 2020 14:48:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Proc-Reg-generate-new-variables-from-some-coefficients/m-p/647487#M78615</guid>
      <dc:creator>Golf</dc:creator>
      <dc:date>2020-05-13T14:48:45Z</dc:date>
    </item>
    <item>
      <title>Re: Proc Reg  :  generate new variables from some coefficients</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Proc-Reg-generate-new-variables-from-some-coefficients/m-p/647489#M78617</link>
      <description>It is because I am doing  Dynamic OLS to obtain cointegration relationship.  In this case only some coefficients need to be used instead of all coefficients.&lt;BR /&gt;Thanks.&lt;BR /&gt;PS  Actually, I can estimate all and see the results, then plug in the number.  But I'd like if there exist better way than this.</description>
      <pubDate>Wed, 13 May 2020 14:51:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Proc-Reg-generate-new-variables-from-some-coefficients/m-p/647489#M78617</guid>
      <dc:creator>Golf</dc:creator>
      <dc:date>2020-05-13T14:51:35Z</dc:date>
    </item>
    <item>
      <title>Re: Proc Reg  :  generate new variables from some coefficients</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Proc-Reg-generate-new-variables-from-some-coefficients/m-p/647490#M78618</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/313878"&gt;@Golf&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;PaigeMiller,&lt;BR /&gt;Nope. I don't want predicted value to subtract from y. &lt;BR /&gt;I want to use (b_A)*A + (b_B)*B + (b_C)*C to subtract from y as follow:&lt;BR /&gt;NewVar = y - (b_A)*A - (b_B)*B - (b_C)*C.&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Use PROC SCORE to use the regression coefficients as you show.&lt;/P&gt;
&lt;P&gt;Here's an example:&amp;nbsp;&lt;A href="https://documentation.sas.com/?cdcId=pgmsascdc&amp;amp;cdcVersion=9.4_3.4&amp;amp;docsetId=statug&amp;amp;docsetTarget=statug_score_examples02.htm&amp;amp;locale=en"&gt;https://documentation.sas.com/?cdcId=pgmsascdc&amp;amp;cdcVersion=9.4_3.4&amp;amp;docsetId=statug&amp;amp;docsetTarget=statug_score_examples02.htm&amp;amp;locale=en&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 13 May 2020 14:52:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Proc-Reg-generate-new-variables-from-some-coefficients/m-p/647490#M78618</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2020-05-13T14:52:09Z</dc:date>
    </item>
    <item>
      <title>Re: Proc Reg  :  generate new variables from some coefficients</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Proc-Reg-generate-new-variables-from-some-coefficients/m-p/647491#M78619</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/313878"&gt;@Golf&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This is untested code:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc reg   data = example outest=parameters; 
model  y =  A B C D E F;
run;

data _null_;
	set parameters;
	call symputx("Intercept", Intercept);
	call symputx("b_A", A);
	call symputx("b_B", B);
	call symputx("b_C", C);
run;

data want;
	set example;
	newvar = y - (&amp;amp;b_A.)*A  - (&amp;amp;b_B.)*B - (&amp;amp;b_C.)*C;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Would that meet your expectations?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best,&lt;/P&gt;</description>
      <pubDate>Wed, 13 May 2020 14:54:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Proc-Reg-generate-new-variables-from-some-coefficients/m-p/647491#M78619</guid>
      <dc:creator>ed_sas_member</dc:creator>
      <dc:date>2020-05-13T14:54:47Z</dc:date>
    </item>
    <item>
      <title>Re: Proc Reg  :  generate new variables from some coefficients</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Proc-Reg-generate-new-variables-from-some-coefficients/m-p/647493#M78620</link>
      <description>Dear ed_sas_member,&lt;BR /&gt;   Thank you so much for your helps.&lt;BR /&gt;Best,</description>
      <pubDate>Wed, 13 May 2020 15:07:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Proc-Reg-generate-new-variables-from-some-coefficients/m-p/647493#M78620</guid>
      <dc:creator>Golf</dc:creator>
      <dc:date>2020-05-13T15:07:19Z</dc:date>
    </item>
    <item>
      <title>Re: Proc Reg  :  generate new variables from some coefficients</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Proc-Reg-generate-new-variables-from-some-coefficients/m-p/647506#M78623</link>
      <description>You're welcome &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/313878"&gt;@Golf&lt;/a&gt; !</description>
      <pubDate>Wed, 13 May 2020 15:38:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Proc-Reg-generate-new-variables-from-some-coefficients/m-p/647506#M78623</guid>
      <dc:creator>ed_sas_member</dc:creator>
      <dc:date>2020-05-13T15:38:17Z</dc:date>
    </item>
  </channel>
</rss>

