<?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, output statement with multiple models in Statistical Procedures</title>
    <link>https://communities.sas.com/t5/Statistical-Procedures/Proc-reg-output-statement-with-multiple-models/m-p/8811#M78</link>
    <description>My conclusion is that with proc REG I MUST ouptput in different datasets to get residuals from different models !&lt;BR /&gt;
(I don't know if the output logic is different in proc glm or other regression procedure)&lt;BR /&gt;
&lt;BR /&gt;
So I have a solution but which is probably not optimal :&lt;BR /&gt;
&lt;BR /&gt;
/* add a raw id to my input data */&lt;BR /&gt;
data Htwt;&lt;BR /&gt;
set Htwt;&lt;BR /&gt;
   RAW_ID = _N_;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
/* run my 2 regressions and output residuals */&lt;BR /&gt;
proc reg data = htwt outest=est1 rsquare;&lt;BR /&gt;
	eq1: model weight=height;&lt;BR /&gt;
	output out = htwt_1 r=res1;&lt;BR /&gt;
	eq2: model weight=height age;&lt;BR /&gt;
	output out = htwt_2 r=res2;&lt;BR /&gt;
run;quit;&lt;BR /&gt;
&lt;BR /&gt;
/* merge back together residuals */&lt;BR /&gt;
proc sort data = htwt_1; by RAW_ID; run;&lt;BR /&gt;
proc sort data = htwt_2; by RAW_ID; run;&lt;BR /&gt;
data htwt_1_2(drop = RAW_ID);&lt;BR /&gt;
merge htwt_1 htwt_2;&lt;BR /&gt;
	by raw_id;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
At the end it may be same processing time than running two time the PROC REG : &lt;BR /&gt;
proc reg data = htwt outest=est1 rsquare;&lt;BR /&gt;
	eq1: model weight=height;&lt;BR /&gt;
	output out = htwt_out r=res1;&lt;BR /&gt;
run;quit;&lt;BR /&gt;
proc reg data = htwt_out outest=est1 rsquare;&lt;BR /&gt;
	eq2: model weight=height age;&lt;BR /&gt;
	output out = htwt_out r=res2;&lt;BR /&gt;
run;quit;&lt;BR /&gt;
&lt;BR /&gt;
Regards,</description>
    <pubDate>Thu, 07 Oct 2010 16:43:57 GMT</pubDate>
    <dc:creator>Antion</dc:creator>
    <dc:date>2010-10-07T16:43:57Z</dc:date>
    <item>
      <title>Proc reg, output statement with multiple models</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Proc-reg-output-statement-with-multiple-models/m-p/8807#M74</link>
      <description>Hi,&lt;BR /&gt;
I am computing mutliple simple linear regressions in the same procedure  'proc reg'. &lt;BR /&gt;
The issue I have is that in the outest I have my 2 regressions with intercept, Rsq ... etc &lt;BR /&gt;
BUT in the output dataset generated with 'output out=' statement (raw data), I can't have residuals for the first model And for the second model : &lt;BR /&gt;
&lt;BR /&gt;
Is anyone can help on that ?&lt;BR /&gt;
&lt;BR /&gt;
proc reg data = htwt outest=est1 rsquare;&lt;BR /&gt;
	eq1: model  weight=height;&lt;BR /&gt;
	eq2: model  weight=height age;&lt;BR /&gt;
	output out = htwt_2 r=res;&lt;BR /&gt;
run;quit;&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
   data htwt;&lt;BR /&gt;
      input sex $ age :3.1 height weight @@;&lt;BR /&gt;
      datalines;&lt;BR /&gt;
   f 143 56.3  85.0 f 155 62.3 105.0 f 153 63.3 108.0 f 161 59.0  92.0&lt;BR /&gt;
   f 191 62.5 112.5 f 171 62.5 112.0 f 185 59.0 104.0 f 142 56.5  69.0&lt;BR /&gt;
   f 160 62.0  94.5 f 140 53.8  68.5 f 139 61.5 104.0 f 178 61.5 103.5&lt;BR /&gt;
   f 157 64.5 123.5 f 149 58.3  93.0 f 143 51.3  50.5 f 145 58.8  89.0 &lt;BR /&gt;
   m 164 66.5 112.0 m 189 65.0 114.0 m 164 61.5 140.0 m 167 62.0 107.5&lt;BR /&gt;
   m 151 59.3  87.0&lt;BR /&gt;
   ;&lt;BR /&gt;
&lt;BR /&gt;
/* data source  */&lt;BR /&gt;
&lt;A href="http://support.sas.com/documentation/cdl/en/statug/63033/HTML/default/viewer.htm#statug_reg_sect056.htm" target="_blank"&gt;http://support.sas.com/documentation/cdl/en/statug/63033/HTML/default/viewer.htm#statug_reg_sect056.htm&lt;/A&gt;&lt;BR /&gt;
&lt;BR /&gt;
Thanks !</description>
      <pubDate>Wed, 29 Sep 2010 09:42:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Proc-reg-output-statement-with-multiple-models/m-p/8807#M74</guid>
      <dc:creator>Antion</dc:creator>
      <dc:date>2010-09-29T09:42:18Z</dc:date>
    </item>
    <item>
      <title>Re: Proc reg, output statement with multiple models</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Proc-reg-output-statement-with-multiple-models/m-p/8808#M75</link>
      <description>Add an OUTPUT statement under EQ1</description>
      <pubDate>Wed, 29 Sep 2010 15:28:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Proc-reg-output-statement-with-multiple-models/m-p/8808#M75</guid>
      <dc:creator>Paige</dc:creator>
      <dc:date>2010-09-29T15:28:31Z</dc:date>
    </item>
    <item>
      <title>Re: Proc reg, output statement with multiple models</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Proc-reg-output-statement-with-multiple-models/m-p/8809#M76</link>
      <description>Ok,&lt;BR /&gt;
Thank you, that makes almost the job. &lt;BR /&gt;
This code outputs 2 datasets that contains the intial data and the residual column.&lt;BR /&gt;
&lt;BR /&gt;
The thing is that I am not able to output in the same dataset !&lt;BR /&gt;
If i try to output in the same dataset i got an error : "ERROR: Data set WORK.HTWT_1 is already open for output."&lt;BR /&gt;
&lt;BR /&gt;
proc reg data = htwt outest=est1 rsquare;&lt;BR /&gt;
   eq1: model weight=height;&lt;BR /&gt;
   output out = htwt_1 r=res1;&lt;BR /&gt;
   eq2: model weight=height age;&lt;BR /&gt;
   output out = htwt_2 r=res2;&lt;BR /&gt;
run;quit;&lt;BR /&gt;
&lt;BR /&gt;
Regards,&lt;BR /&gt;
Antoine</description>
      <pubDate>Tue, 05 Oct 2010 11:11:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Proc-reg-output-statement-with-multiple-models/m-p/8809#M76</guid>
      <dc:creator>Antion</dc:creator>
      <dc:date>2010-10-05T11:11:09Z</dc:date>
    </item>
    <item>
      <title>Re: Proc reg, output statement with multiple models</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Proc-reg-output-statement-with-multiple-models/m-p/8810#M77</link>
      <description>&amp;gt; The thing is that I am not able to output in the same&lt;BR /&gt;
&amp;gt; dataset !&lt;BR /&gt;
&lt;BR /&gt;
I don't think this is possible from PROC REG.&lt;BR /&gt;
&lt;BR /&gt;
If only SAS provided a way to MERGE data sets! That would solve the problem!

Message was edited by: Paige</description>
      <pubDate>Tue, 05 Oct 2010 12:42:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Proc-reg-output-statement-with-multiple-models/m-p/8810#M77</guid>
      <dc:creator>Paige</dc:creator>
      <dc:date>2010-10-05T12:42:53Z</dc:date>
    </item>
    <item>
      <title>Re: Proc reg, output statement with multiple models</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Proc-reg-output-statement-with-multiple-models/m-p/8811#M78</link>
      <description>My conclusion is that with proc REG I MUST ouptput in different datasets to get residuals from different models !&lt;BR /&gt;
(I don't know if the output logic is different in proc glm or other regression procedure)&lt;BR /&gt;
&lt;BR /&gt;
So I have a solution but which is probably not optimal :&lt;BR /&gt;
&lt;BR /&gt;
/* add a raw id to my input data */&lt;BR /&gt;
data Htwt;&lt;BR /&gt;
set Htwt;&lt;BR /&gt;
   RAW_ID = _N_;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
/* run my 2 regressions and output residuals */&lt;BR /&gt;
proc reg data = htwt outest=est1 rsquare;&lt;BR /&gt;
	eq1: model weight=height;&lt;BR /&gt;
	output out = htwt_1 r=res1;&lt;BR /&gt;
	eq2: model weight=height age;&lt;BR /&gt;
	output out = htwt_2 r=res2;&lt;BR /&gt;
run;quit;&lt;BR /&gt;
&lt;BR /&gt;
/* merge back together residuals */&lt;BR /&gt;
proc sort data = htwt_1; by RAW_ID; run;&lt;BR /&gt;
proc sort data = htwt_2; by RAW_ID; run;&lt;BR /&gt;
data htwt_1_2(drop = RAW_ID);&lt;BR /&gt;
merge htwt_1 htwt_2;&lt;BR /&gt;
	by raw_id;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
At the end it may be same processing time than running two time the PROC REG : &lt;BR /&gt;
proc reg data = htwt outest=est1 rsquare;&lt;BR /&gt;
	eq1: model weight=height;&lt;BR /&gt;
	output out = htwt_out r=res1;&lt;BR /&gt;
run;quit;&lt;BR /&gt;
proc reg data = htwt_out outest=est1 rsquare;&lt;BR /&gt;
	eq2: model weight=height age;&lt;BR /&gt;
	output out = htwt_out r=res2;&lt;BR /&gt;
run;quit;&lt;BR /&gt;
&lt;BR /&gt;
Regards,</description>
      <pubDate>Thu, 07 Oct 2010 16:43:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Proc-reg-output-statement-with-multiple-models/m-p/8811#M78</guid>
      <dc:creator>Antion</dc:creator>
      <dc:date>2010-10-07T16:43:57Z</dc:date>
    </item>
    <item>
      <title>Re: Proc reg, output statement with multiple models</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Proc-reg-output-statement-with-multiple-models/m-p/8812#M79</link>
      <description>Sorting is unnecessary, as is the step containing RAW_ID = _N_;&lt;BR /&gt;
&lt;BR /&gt;
Both output data sets are in the exact same sequence, and so you can simply do the merge without the BY statement here.</description>
      <pubDate>Thu, 07 Oct 2010 16:58:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Proc-reg-output-statement-with-multiple-models/m-p/8812#M79</guid>
      <dc:creator>Paige</dc:creator>
      <dc:date>2010-10-07T16:58:46Z</dc:date>
    </item>
  </channel>
</rss>

