<?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: predicting outcome values with lsmeans in quadratic regression in Statistical Procedures</title>
    <link>https://communities.sas.com/t5/Statistical-Procedures/predicting-outcome-values-with-lsmeans-in-quadratic-regression/m-p/983799#M49292</link>
    <description>&lt;P&gt;Fantastic, thank you so much Ksharp!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Is there a way to also include the observed DM values in the table?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks!&lt;/P&gt;</description>
    <pubDate>Fri, 20 Feb 2026 16:35:24 GMT</pubDate>
    <dc:creator>palolix</dc:creator>
    <dc:date>2026-02-20T16:35:24Z</dc:date>
    <item>
      <title>predicting outcome values with lsmeans in quadratic regression</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/predicting-outcome-values-with-lsmeans-in-quadratic-regression/m-p/983438#M49233</link>
      <description>&lt;P&gt;Dear SAS Communities,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I was trying to predict outcome values for a continuous variable (DM) after fitting a quadratic regression in proc glm&lt;/P&gt;
&lt;P&gt;I would like to know the dry matter (DM) values when hedonic (categorical predictor variable) is 5, 5.5, and 6.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I was trying this model but I get this error: Wrong number of AT variable values&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc glm data=one;&lt;BR /&gt;model DM= hedonic hedonic*hedonic;&lt;BR /&gt;lsmeans/at hedonic = (5&amp;nbsp; 5.5&amp;nbsp; 6) pdiff;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I would greatly appreciate your help!&lt;/P&gt;</description>
      <pubDate>Fri, 13 Feb 2026 01:34:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/predicting-outcome-values-with-lsmeans-in-quadratic-regression/m-p/983438#M49233</guid>
      <dc:creator>palolix</dc:creator>
      <dc:date>2026-02-13T01:34:01Z</dc:date>
    </item>
    <item>
      <title>Re: predicting outcome values with lsmeans in quadratic regression</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/predicting-outcome-values-with-lsmeans-in-quadratic-regression/m-p/983443#M49235</link>
      <description>&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13684"&gt;@Rick_SAS&lt;/a&gt; wrote a blog about this:&lt;BR /&gt;&lt;A href="https://blogs.sas.com/content/iml/2014/02/19/scoring-a-regression-model-in-sas.html" target="_blank"&gt;https://blogs.sas.com/content/iml/2014/02/19/scoring-a-regression-model-in-sas.html&lt;/A&gt;</description>
      <pubDate>Fri, 13 Feb 2026 07:03:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/predicting-outcome-values-with-lsmeans-in-quadratic-regression/m-p/983443#M49235</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2026-02-13T07:03:13Z</dc:date>
    </item>
    <item>
      <title>Re: predicting outcome values with lsmeans in quadratic regression</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/predicting-outcome-values-with-lsmeans-in-quadratic-regression/m-p/983445#M49236</link>
      <description>&lt;P&gt;If&amp;nbsp;&lt;SPAN&gt;hedonic is a "categorical predictor variable," you should include a CLASS statement? For a classification variable, you can only evaluate the model at levels that are in the model. If you model hedonic as a continuous variable, you can evaluate the model at values that are not in the input data.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;From your description, it sounds like you want the predicted value of the model at specific values of the independent variable. As KSharp says, the simplest way to get that information is to "score" (or evaluate) the model at specific values of hedonic by using the STORE statement to save the model and the PLM procedure to evaluate the model at the specified values. Here is an example that uses the Sashelp.Class data:&lt;BR /&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc glm data=sashelp.class plots=none;
/* class age; */ /* ??? Treat as categorical?  */
model Weight= age age*age;
store out=GLMModel;
quit;

data AtLevels;
input Age @@;
datalines;
12 12.5 14 16
;

proc plm restore=GLMModel;
  score data=AtLevels out=GLMOut;
run;

proc print; run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;SPAN&gt;The input data does not contain any subjects with Age=12.5.&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;If you include the CLASS statement, the model cannot form a prediction at Age=12.5. However, if you treat Age as a continuous variable, the model can&amp;nbsp;calculate the predicted value.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 13 Feb 2026 10:49:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/predicting-outcome-values-with-lsmeans-in-quadratic-regression/m-p/983445#M49236</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2026-02-13T10:49:10Z</dc:date>
    </item>
    <item>
      <title>Re: predicting outcome values with lsmeans in quadratic regression</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/predicting-outcome-values-with-lsmeans-in-quadratic-regression/m-p/983662#M49285</link>
      <description>&lt;P&gt;Thank you so much for your reply Rick_SAS and Ksharp! With this approach and also with the following one I get the predicted DM values for the 9 levels of the predictor when using means of the reps, but if I use the raw data (N =555), I get predicted DM values for 555 observations (for the individual reps). Is there a way to get the predicted DM values for the 9 levels of the predictor (hedonic) using the raw data instead of the means?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data poly_data;&lt;BR /&gt;set one_means;&lt;BR /&gt;hedonic2 = hedonic**2;&lt;BR /&gt;hedonic3 = hedonic**3;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;DIV&gt;proc glm data=poly_data;&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp; &amp;nbsp; model DM = hedonic hedonic2 hedonic3/p solution alpha=.05 clparm;&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN&gt; run;&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN&gt;Thank you very much!&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;</description>
      <pubDate>Wed, 18 Feb 2026 03:16:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/predicting-outcome-values-with-lsmeans-in-quadratic-regression/m-p/983662#M49285</guid>
      <dc:creator>palolix</dc:creator>
      <dc:date>2026-02-18T03:16:39Z</dc:date>
    </item>
    <item>
      <title>Re: predicting outcome values with lsmeans in quadratic regression</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/predicting-outcome-values-with-lsmeans-in-quadratic-regression/m-p/983683#M49286</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/* create fake data set that has the same names as the OP's data */
%let Orig_Data = sashelp.class;
data poly_data;
set &amp;amp;Orig_Data;
DM = Weight;
hedonic = Age;
hedonic2 = hedonic**2;
hedonic3 = hedonic**3;
keep DM hedonic hedonic2 hedonic3;
run;

proc glm data=poly_data;
    model DM = hedonic hedonic2 hedonic3/p solution alpha=.05 clparm;
    output out=GLMOut Predicted=Pred;
quit; &lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Of course, any obs with the same value of hedonic will have the same predicted value. If you want to see only the unique predictions, you can sort by hedonic and then output only the first observation for each level:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sort data=GLMOut;
by hedonic;
run;

data GLMOut_NoDups;
set GLMOut;
by hedonic;
if first.hedonic;
run;

proc print; run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 19 Feb 2026 13:45:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/predicting-outcome-values-with-lsmeans-in-quadratic-regression/m-p/983683#M49286</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2026-02-19T13:45:50Z</dc:date>
    </item>
    <item>
      <title>Re: predicting outcome values with lsmeans in quadratic regression</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/predicting-outcome-values-with-lsmeans-in-quadratic-regression/m-p/983723#M49288</link>
      <description>&lt;P&gt;It worked, thank you so much!! I guess I have to omit the statements&amp;nbsp;&lt;/P&gt;
&lt;P&gt;DM = Weight&amp;nbsp;&lt;/P&gt;
&lt;P&gt;hedonic = Age&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 18 Feb 2026 20:45:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/predicting-outcome-values-with-lsmeans-in-quadratic-regression/m-p/983723#M49288</guid>
      <dc:creator>palolix</dc:creator>
      <dc:date>2026-02-18T20:45:32Z</dc:date>
    </item>
    <item>
      <title>Re: predicting outcome values with lsmeans in quadratic regression</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/predicting-outcome-values-with-lsmeans-in-quadratic-regression/m-p/983773#M49289</link>
      <description>&lt;P&gt;Thank you so much for your support. One more question. Is there a way to get values for hedonic in increments of .05? To include a statement like this in this code?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc glm data=poly_data;&lt;BR /&gt;model DM = hedonic hedonic2/p solution alpha=.05 clparm;&lt;BR /&gt;output out=GLMOut Predicted=Pred;&lt;BR /&gt;quit;&lt;/P&gt;
&lt;P&gt;proc sort data=GLMOut;&lt;BR /&gt;by hedonic;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data GLMOut_NoDups;&lt;BR /&gt;set GLMOut;&lt;BR /&gt;by hedonic;&lt;BR /&gt;&lt;STRONG&gt;do hedonic = 1 to 9 by .5;&lt;/STRONG&gt;&lt;BR /&gt;if first.hedonic;&lt;BR /&gt;run;&lt;/P&gt;</description>
      <pubDate>Fri, 20 Feb 2026 02:12:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/predicting-outcome-values-with-lsmeans-in-quadratic-regression/m-p/983773#M49289</guid>
      <dc:creator>palolix</dc:creator>
      <dc:date>2026-02-20T02:12:27Z</dc:date>
    </item>
    <item>
      <title>Re: predicting outcome values with lsmeans in quadratic regression</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/predicting-outcome-values-with-lsmeans-in-quadratic-regression/m-p/983776#M49291</link>
      <description>&lt;P&gt;You could get any value of "hedonic&amp;nbsp;" you want, make a test dataset to include the value you want to predict.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;%let Orig_Data = sashelp.class;
data poly_data;
set &amp;amp;Orig_Data;
DM = Weight;
hedonic = Age;
hedonic2 = hedonic**2;
hedonic3 = hedonic**3;
keep DM hedonic hedonic2 hedonic3;
run;
&lt;STRONG&gt;
data test;
do hedonic = 1 to 9 by .5;
 hedonic2 = hedonic**2;
 hedonic3 = hedonic**3;
 output;
end;
run;&lt;/STRONG&gt;

data poly_data2;
 length dsname dsn $ 40;
 set poly_data test indsname=dsname;
 dsn=dsname;
run;

proc glm data=poly_data2;
    model DM = hedonic hedonic2 hedonic3/p solution alpha=.05 clparm;
    output out=GLMOut Predicted=Pred;
quit; 

proc print data=GLMOut(where=(dsn='WORK.TEST'));run;
run;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Ksharp_0-1771557441442.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/113264i720DEF9B75EAABD3/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Ksharp_0-1771557441442.png" alt="Ksharp_0-1771557441442.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 20 Feb 2026 03:17:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/predicting-outcome-values-with-lsmeans-in-quadratic-regression/m-p/983776#M49291</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2026-02-20T03:17:31Z</dc:date>
    </item>
    <item>
      <title>Re: predicting outcome values with lsmeans in quadratic regression</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/predicting-outcome-values-with-lsmeans-in-quadratic-regression/m-p/983799#M49292</link>
      <description>&lt;P&gt;Fantastic, thank you so much Ksharp!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Is there a way to also include the observed DM values in the table?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Fri, 20 Feb 2026 16:35:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/predicting-outcome-values-with-lsmeans-in-quadratic-regression/m-p/983799#M49292</guid>
      <dc:creator>palolix</dc:creator>
      <dc:date>2026-02-20T16:35:24Z</dc:date>
    </item>
    <item>
      <title>Re: predicting outcome values with lsmeans in quadratic regression</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/predicting-outcome-values-with-lsmeans-in-quadratic-regression/m-p/983819#M49293</link>
      <description>What do you mean by "observed DM values" ?&lt;BR /&gt;In TEST dataset , you don't have observed DM, you only have predicted value of DM . &lt;BR /&gt;If you want to include observed DM from original dataset, you could remove the WHERE condition in PROC PRINT:&lt;BR /&gt;&lt;BR /&gt;proc print data=GLMOut;run;&lt;BR /&gt;run;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Or pick up the value of hedonic you need:&lt;BR /&gt;proc print data=GLMOut(where=(hedonic in (1 2 3 4)));run;&lt;BR /&gt;run;</description>
      <pubDate>Sat, 21 Feb 2026 02:27:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/predicting-outcome-values-with-lsmeans-in-quadratic-regression/m-p/983819#M49293</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2026-02-21T02:27:01Z</dc:date>
    </item>
    <item>
      <title>Re: predicting outcome values with lsmeans in quadratic regression</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/predicting-outcome-values-with-lsmeans-in-quadratic-regression/m-p/983828#M49294</link>
      <description>&lt;P&gt;In addition to what KSharp said in his reply, the observed DM values are not important when scoring the model.&amp;nbsp;The predicted values depend only on the explanatory variable(s). The DM is only used during the fitting processes. It is also used to form residuals, which are useful for assessing the goodness of the fit.&lt;/P&gt;</description>
      <pubDate>Sat, 21 Feb 2026 11:23:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/predicting-outcome-values-with-lsmeans-in-quadratic-regression/m-p/983828#M49294</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2026-02-21T11:23:40Z</dc:date>
    </item>
    <item>
      <title>Re: predicting outcome values with lsmeans in quadratic regression</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/predicting-outcome-values-with-lsmeans-in-quadratic-regression/m-p/984105#M49298</link>
      <description>&lt;P&gt;Oh ok, thank you for the clarification!&lt;/P&gt;</description>
      <pubDate>Wed, 25 Feb 2026 23:56:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/predicting-outcome-values-with-lsmeans-in-quadratic-regression/m-p/984105#M49298</guid>
      <dc:creator>palolix</dc:creator>
      <dc:date>2026-02-25T23:56:42Z</dc:date>
    </item>
    <item>
      <title>Re: predicting outcome values with lsmeans in quadratic regression</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/predicting-outcome-values-with-lsmeans-in-quadratic-regression/m-p/984106#M49299</link>
      <description>&lt;P&gt;Thank you very much for your input Rick_SAS!&lt;/P&gt;</description>
      <pubDate>Wed, 25 Feb 2026 23:57:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/predicting-outcome-values-with-lsmeans-in-quadratic-regression/m-p/984106#M49299</guid>
      <dc:creator>palolix</dc:creator>
      <dc:date>2026-02-25T23:57:53Z</dc:date>
    </item>
  </channel>
</rss>

