<?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 Regression-save resgression equation on macro variable in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Regression-save-resgression-equation-on-macro-variable/m-p/729644#M227104</link>
    <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;I saw this code that creates a regression model to &lt;SPAN&gt;use a person's&amp;nbsp;&lt;/SPAN&gt;&lt;EM&gt;height&lt;/EM&gt;&lt;SPAN&gt;&amp;nbsp;to&amp;nbsp;&lt;/SPAN&gt;&lt;EM&gt;predict&lt;/EM&gt;&lt;SPAN&gt;&amp;nbsp;the person's&amp;nbsp;&lt;/SPAN&gt;&lt;EM&gt;weight.&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;I read about defintions of&amp;nbsp;Training dataset and Test(validation)&amp;nbsp;data set.&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;Training dataset: &lt;/EM&gt;data&amp;nbsp;used to&amp;nbsp;create the model&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Test(validation)&amp;nbsp;data set&amp;nbsp;:&amp;nbsp;data used to&amp;nbsp;qualify performance(check performance of regression model)&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000000"&gt;&lt;U&gt;&lt;EM&gt;I have 3 questions:&lt;/EM&gt;&lt;/U&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;I&gt;1-Why in the code put the train table and test table together? (As I read&amp;nbsp; we need to build the model on the train table only)&lt;/I&gt;&lt;/P&gt;
&lt;P&gt;&lt;I&gt;2-What is the meaning of&amp;nbsp;&lt;CODE class=" language-sas"&gt;outest=est (in proc sgplot)? &lt;/CODE&gt;&lt;/I&gt;&lt;/P&gt;
&lt;P&gt;&lt;I&gt;3-We saved the resgression equation on macro variable and used it to calculate precited values for new observations from train data.&lt;/I&gt;&lt;/P&gt;
&lt;P&gt;&lt;I&gt;Is it the only way to do it?&lt;/I&gt;&lt;/P&gt;
&lt;P&gt;&lt;I&gt;If we have 50 independent varaibles then it might be too long code..&lt;/I&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;PRE&gt;&lt;CODE class=" language-sas"&gt;
data train;
set sashelp.class(keep=weight height);
run;

data test;
 height=71;output;
 height=72;output;
run;

data have;
 set train test;
run;

proc reg data=have outest=est noprint;
model weight=height;
output out=want predicted=predicted;
run;

proc print data=want noobs;run;

data _null_;
set est;
call symputx('func',cats('weight=',intercept,'+',height,'*height'));
run;

proc sgplot data=train aspect=1;
reg x=height y=weight/ cli clm;
inset "&amp;amp;func"/ position=topleft textattrs=graphdata1(size=12);
run;


&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sun, 28 Mar 2021 18:09:40 GMT</pubDate>
    <dc:creator>Ronein</dc:creator>
    <dc:date>2021-03-28T18:09:40Z</dc:date>
    <item>
      <title>Regression-save resgression equation on macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Regression-save-resgression-equation-on-macro-variable/m-p/729644#M227104</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;I saw this code that creates a regression model to &lt;SPAN&gt;use a person's&amp;nbsp;&lt;/SPAN&gt;&lt;EM&gt;height&lt;/EM&gt;&lt;SPAN&gt;&amp;nbsp;to&amp;nbsp;&lt;/SPAN&gt;&lt;EM&gt;predict&lt;/EM&gt;&lt;SPAN&gt;&amp;nbsp;the person's&amp;nbsp;&lt;/SPAN&gt;&lt;EM&gt;weight.&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;I read about defintions of&amp;nbsp;Training dataset and Test(validation)&amp;nbsp;data set.&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;Training dataset: &lt;/EM&gt;data&amp;nbsp;used to&amp;nbsp;create the model&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Test(validation)&amp;nbsp;data set&amp;nbsp;:&amp;nbsp;data used to&amp;nbsp;qualify performance(check performance of regression model)&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000000"&gt;&lt;U&gt;&lt;EM&gt;I have 3 questions:&lt;/EM&gt;&lt;/U&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;I&gt;1-Why in the code put the train table and test table together? (As I read&amp;nbsp; we need to build the model on the train table only)&lt;/I&gt;&lt;/P&gt;
&lt;P&gt;&lt;I&gt;2-What is the meaning of&amp;nbsp;&lt;CODE class=" language-sas"&gt;outest=est (in proc sgplot)? &lt;/CODE&gt;&lt;/I&gt;&lt;/P&gt;
&lt;P&gt;&lt;I&gt;3-We saved the resgression equation on macro variable and used it to calculate precited values for new observations from train data.&lt;/I&gt;&lt;/P&gt;
&lt;P&gt;&lt;I&gt;Is it the only way to do it?&lt;/I&gt;&lt;/P&gt;
&lt;P&gt;&lt;I&gt;If we have 50 independent varaibles then it might be too long code..&lt;/I&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;PRE&gt;&lt;CODE class=" language-sas"&gt;
data train;
set sashelp.class(keep=weight height);
run;

data test;
 height=71;output;
 height=72;output;
run;

data have;
 set train test;
run;

proc reg data=have outest=est noprint;
model weight=height;
output out=want predicted=predicted;
run;

proc print data=want noobs;run;

data _null_;
set est;
call symputx('func',cats('weight=',intercept,'+',height,'*height'));
run;

proc sgplot data=train aspect=1;
reg x=height y=weight/ cli clm;
inset "&amp;amp;func"/ position=topleft textattrs=graphdata1(size=12);
run;


&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 28 Mar 2021 18:09:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Regression-save-resgression-equation-on-macro-variable/m-p/729644#M227104</guid>
      <dc:creator>Ronein</dc:creator>
      <dc:date>2021-03-28T18:09:40Z</dc:date>
    </item>
    <item>
      <title>Re: Regression-save resgression equation on macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Regression-save-resgression-equation-on-macro-variable/m-p/729659#M227111</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159549"&gt;@Ronein&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;I saw this code that creates a regression model to &lt;SPAN&gt;use a person's&amp;nbsp;&lt;/SPAN&gt;&lt;EM&gt;height&lt;/EM&gt;&lt;SPAN&gt;&amp;nbsp;to&amp;nbsp;&lt;/SPAN&gt;&lt;EM&gt;predict&lt;/EM&gt;&lt;SPAN&gt;&amp;nbsp;the person's&amp;nbsp;&lt;/SPAN&gt;&lt;EM&gt;weight.&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;I read about defintions of&amp;nbsp;Training dataset and Test(validation)&amp;nbsp;data set.&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;Training dataset: &lt;/EM&gt;data&amp;nbsp;used to&amp;nbsp;create the model&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Test(validation)&amp;nbsp;data set&amp;nbsp;:&amp;nbsp;data used to&amp;nbsp;qualify performance(check performance of regression model)&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000000"&gt;&lt;U&gt;&lt;EM&gt;I have 3 questions:&lt;/EM&gt;&lt;/U&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;I&gt;1-Why in the code put the train table and test table together? (As I read&amp;nbsp; we need to build the model on the train table only)&lt;/I&gt;&lt;/P&gt;
&lt;P&gt;&lt;I&gt;2-What is the meaning of&amp;nbsp;&lt;CODE class=" language-sas"&gt;outest=est (in proc sgplot)? &lt;/CODE&gt;&lt;/I&gt;&lt;/P&gt;
&lt;P&gt;&lt;I&gt;3-We saved the resgression equation on macro variable and used it to calculate precited values for new observations from train data.&lt;/I&gt;&lt;/P&gt;
&lt;P&gt;&lt;I&gt;Is it the only way to do it?&lt;/I&gt;&lt;/P&gt;
&lt;P&gt;&lt;I&gt;If we have 50 independent varaibles then it might be too long code..&lt;/I&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;PRE&gt;&lt;CODE class=" language-sas"&gt;
data train;
set sashelp.class(keep=weight height);
run;

data test;
 height=71;output;
 height=72;output;
run;

data have;
 set train test;
run;

proc reg data=have outest=est noprint;
model weight=height;
output out=want predicted=predicted;
run;

proc print data=want noobs;run;

data _null_;
set est;
call symputx('func',cats('weight=',intercept,'+',height,'*height'));
run;

proc sgplot data=train aspect=1;
reg x=height y=weight/ cli clm;
inset "&amp;amp;func"/ position=topleft textattrs=graphdata1(size=12);
run;


&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;OL&gt;
&lt;LI&gt;The train and test data sets are combined, and then PROC REG will use the train data only to create the regression equation since only the train portion of the data has actual non-missing Y values, but it will give predicted values and confidence intervals on the records in both the train and test data sets.&lt;/LI&gt;
&lt;LI&gt;OUTEST=EST (surely you can look up what a specific option does in the SAS documentation, after all this time you have been using the forum)&lt;/LI&gt;
&lt;LI&gt;Macro variables are the WORST way to save the regression equation, WORST in the sense don't do it because its a lot of effort and there are much simpler ways! The regression equation can be saved in a data set and used for later calculations via PROC SCORE; or they can be saved using the STORE statement in PROC REG and then the predicted values can be computed by PROC PLM. None of this requires you to code the actual prediction equation, SAS handles all of this for you regardless of how many variables are in the regression equation. Look at examples under PROC SCORE or PROC PLM. As far as putting the regression equation in PROC SGPLOT INSET with more than one X variable, this makes no sense. You can't plot the regression with more than one X variable.&lt;/LI&gt;
&lt;/OL&gt;</description>
      <pubDate>Sun, 28 Mar 2021 20:08:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Regression-save-resgression-equation-on-macro-variable/m-p/729659#M227111</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2021-03-28T20:08:04Z</dc:date>
    </item>
  </channel>
</rss>

