<?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: How to calculate difference of means with interaction term using lsmestimate in Statistical Procedures</title>
    <link>https://communities.sas.com/t5/Statistical-Procedures/How-to-calculate-difference-of-means-with-interaction-term-using/m-p/608695#M29491</link>
    <description>&lt;P&gt;This is exactly what the SLICE command in PROC LOGISTIC does.&lt;/P&gt;
&lt;P&gt;&lt;A href="https://documentation.sas.com/?docsetId=statug&amp;amp;docsetTarget=statug_introcom_sect064.htm&amp;amp;docsetVersion=14.3&amp;amp;locale=en"&gt;https://documentation.sas.com/?docsetId=statug&amp;amp;docsetTarget=statug_introcom_sect064.htm&amp;amp;docsetVersion=14.3&amp;amp;locale=en&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;An example of using SLICE is given here (scroll down)&lt;/P&gt;
&lt;P&gt;&lt;A href="https://documentation.sas.com/?cdcId=pgmsascdc&amp;amp;cdcVersion=9.4_3.4&amp;amp;docsetId=statug&amp;amp;docsetTarget=statug_logistic_examples21.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_logistic_examples21.htm&amp;amp;locale=en&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Additionally, you wouldn't normally use LSMESTIMATE or ESTIMATE if all you are doing is comparing one level to another level. Usually, the only time you need LSMESTIMATE or ESTIMATE is if you, for some reason, want to create estimates where the comparisons are not one level to another, for example, if you wanted –1*(level 1)+2*(level 2)–1*(level 3).&lt;/P&gt;</description>
    <pubDate>Mon, 02 Dec 2019 13:21:40 GMT</pubDate>
    <dc:creator>PaigeMiller</dc:creator>
    <dc:date>2019-12-02T13:21:40Z</dc:date>
    <item>
      <title>How to calculate difference of means with interaction term using lsmestimate</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/How-to-calculate-difference-of-means-with-interaction-term-using/m-p/608607#M29490</link>
      <description>&lt;P&gt;Hi, I have a this program to calculate the hospital use according to the number of disease and the age. The number of disease has been coded into 5 categories (0 to 4) and the age also has 5 categories (1 (youngest) to 5(oldest)). We also added an interaction term between age and number of disease. I'm trying to calculate the difference between the oldest and the youngest group for each category of disease. I know we van use the lsmestimate procedure but I'm having a hard time to figure out where to place the zeros and ones, etc. This is my code :&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;PROC LOGISTIC desc DATA=exemple;&lt;BR /&gt;Class disease (ref='0') age (ref='1')/ param=glm;&lt;BR /&gt;Model hospital = disease age disease*age;&lt;BR /&gt;lsmeans disease age disease*age/ diff ilink cl e exp;&lt;BR /&gt;lsmestimate 'diff age 5 - age 1 for disease = 0' 0 0 0 0 0&amp;nbsp; 1 0 0 0 -1/&amp;nbsp;ilink cl e exp;&lt;/P&gt;&lt;P&gt;lsmestimate 'diff age 5 - age 1 for disease = 1' 0 1 0 0 0&amp;nbsp; 1 0 0 0 -1/ ilink cl e exp;&lt;/P&gt;&lt;P&gt;lsmestimate 'diff age 5 - age 1 for disease = 2'&amp;nbsp;0 0 1 0 0&amp;nbsp; 1 0 0 0 -1/ilink cl e exp;&lt;/P&gt;&lt;P&gt;lsmestimate 'diff age 5 - age 1 for disease = 3' 0 0 0 1 0&amp;nbsp; 1 0 0 0 -1/ilink cl e exp;&lt;/P&gt;&lt;P&gt;lsmestimate 'diff age 5 - age 1 for disease = 4' 0 0 0 0 1&amp;nbsp; 1 0 0 0 -1/ilink cl e exp;&lt;BR /&gt;RUN;&lt;/P&gt;</description>
      <pubDate>Sun, 01 Dec 2019 23:16:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/How-to-calculate-difference-of-means-with-interaction-term-using/m-p/608607#M29490</guid>
      <dc:creator>Porscha</dc:creator>
      <dc:date>2019-12-01T23:16:17Z</dc:date>
    </item>
    <item>
      <title>Re: How to calculate difference of means with interaction term using lsmestimate</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/How-to-calculate-difference-of-means-with-interaction-term-using/m-p/608695#M29491</link>
      <description>&lt;P&gt;This is exactly what the SLICE command in PROC LOGISTIC does.&lt;/P&gt;
&lt;P&gt;&lt;A href="https://documentation.sas.com/?docsetId=statug&amp;amp;docsetTarget=statug_introcom_sect064.htm&amp;amp;docsetVersion=14.3&amp;amp;locale=en"&gt;https://documentation.sas.com/?docsetId=statug&amp;amp;docsetTarget=statug_introcom_sect064.htm&amp;amp;docsetVersion=14.3&amp;amp;locale=en&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;An example of using SLICE is given here (scroll down)&lt;/P&gt;
&lt;P&gt;&lt;A href="https://documentation.sas.com/?cdcId=pgmsascdc&amp;amp;cdcVersion=9.4_3.4&amp;amp;docsetId=statug&amp;amp;docsetTarget=statug_logistic_examples21.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_logistic_examples21.htm&amp;amp;locale=en&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Additionally, you wouldn't normally use LSMESTIMATE or ESTIMATE if all you are doing is comparing one level to another level. Usually, the only time you need LSMESTIMATE or ESTIMATE is if you, for some reason, want to create estimates where the comparisons are not one level to another, for example, if you wanted –1*(level 1)+2*(level 2)–1*(level 3).&lt;/P&gt;</description>
      <pubDate>Mon, 02 Dec 2019 13:21:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/How-to-calculate-difference-of-means-with-interaction-term-using/m-p/608695#M29491</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2019-12-02T13:21:40Z</dc:date>
    </item>
    <item>
      <title>Re: How to calculate difference of means with interaction term using lsmestimate</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/How-to-calculate-difference-of-means-with-interaction-term-using/m-p/608846#M29494</link>
      <description>&lt;P&gt;Check the syntax for the LSMESTIMATE statement&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="left: 142.785px; top: 1015.34px; font-size: 15px; font-family: sans-serif; transform: scaleX(1.08524);"&gt;LSMESTIMATE &lt;/SPAN&gt;&lt;SPAN style="left: 254.58px; top: 1017.03px; font-size: 15px; font-family: sans-serif; transform: scaleX(1.14375);"&gt;&lt;FONT color="#0000FF"&gt;fixed-effect&lt;/FONT&gt; &amp;lt;&lt;/SPAN&gt;&lt;SPAN style="left: 340.98px; top: 1017.0310817708332px; font-size: 14.999999999999998px; font-family: sans-serif;"&gt;'&lt;/SPAN&gt;&lt;SPAN style="left: 343.74px; top: 1017.03px; font-size: 15px; font-family: sans-serif; transform: scaleX(1.0595);"&gt;label&lt;/SPAN&gt;&lt;SPAN style="left: 375.52514999999994px; top: 1017.0310817708332px; font-size: 14.999999999999998px; font-family: sans-serif;"&gt;'&lt;/SPAN&gt;&lt;SPAN style="left: 378.525px; top: 1017.03px; font-size: 15px; font-family: sans-serif; transform: scaleX(1.01852);"&gt;&amp;gt; values &amp;lt;divisor=&amp;gt; &lt;/SPAN&gt;&lt;SPAN style="left: 311.4px; top: 1034.43px; font-size: 15px; font-family: sans-serif; transform: scaleX(0.999808);"&gt;&amp;lt;, &amp;lt;&lt;/SPAN&gt;&lt;SPAN style="left: 337.39515px; top: 1034.431081770833px; font-size: 14.999999999999998px; font-family: sans-serif;"&gt;'&lt;/SPAN&gt;&lt;SPAN style="left: 340.365px; top: 1034.43px; font-size: 15px; font-family: sans-serif; transform: scaleX(1.06);"&gt;label&lt;/SPAN&gt;&lt;SPAN style="left: 372.1648499999999px; top: 1034.431081770833px; font-size: 14.999999999999998px; font-family: sans-serif;"&gt;'&lt;/SPAN&gt;&lt;SPAN style="left: 374.7px; top: 1034.43px; font-size: 15px; font-family: sans-serif; transform: scaleX(1.01489);"&gt;&amp;gt; values &amp;lt;divisor=&amp;gt;&amp;gt; &amp;lt;, ...&amp;gt;&lt;/SPAN&gt;&lt;SPAN style="left: 247.59px; top: 1051.83px; font-size: 15px; font-family: sans-serif; transform: scaleX(1.01753);"&gt;&amp;lt; / options&amp;gt; ;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="left: 247.59px; top: 1051.83px; font-size: 15px; font-family: sans-serif; transform: scaleX(1.01753);"&gt;You will see that your statement fails to include a &lt;FONT color="#0000FF"&gt;fixed-effect&lt;/FONT&gt;. &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="left: 247.59px; top: 1051.83px; font-size: 15px; font-family: sans-serif; transform: scaleX(1.01753);"&gt;This paper by Kiernan et al. contains a lot of information that you will probably find useful&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="left: 247.59px; top: 1051.83px; font-size: 15px; font-family: sans-serif; transform: scaleX(1.01753);"&gt;&lt;A href="https://www.pharmasug.org/proceedings/2011/SAS/PharmaSUG-2011-SAS-SP01.pdf" target="_self"&gt;CONTRAST and ESTIMATE Statements Made Easy: The LSMESTIMATE Statement&lt;/A&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="left: 247.59px; top: 1051.83px; font-size: 15px; font-family: sans-serif; transform: scaleX(1.01753);"&gt;In particular, for a contrast involving a 5x5 interaction I would use "non-positional syntax" (p 5 in the paper); it's a lot easier than trying to figure out where to put a "1" and a "-1" and 23 zeros in a set of 25 coefficients.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="left: 247.59px; top: 1051.83px; font-size: 15px; font-family: sans-serif; transform: scaleX(1.01753);"&gt;I hope this helps.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 02 Dec 2019 20:59:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/How-to-calculate-difference-of-means-with-interaction-term-using/m-p/608846#M29494</guid>
      <dc:creator>sld</dc:creator>
      <dc:date>2019-12-02T20:59:32Z</dc:date>
    </item>
    <item>
      <title>Re: How to calculate difference of means with interaction term using lsmestimate</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/How-to-calculate-difference-of-means-with-interaction-term-using/m-p/609097#M29502</link>
      <description>&lt;P&gt;First, if there are five levels of both variables then there will be 25 mean estimates from the LSMEANS statement. If you want to compare two particular means, look at the table presented by the LSMEANS statement and specify 25 coefficients matching the order of means in that table in your LSMESTIMATE statement. For instance, if you want to compare the first two means (first - second), then specify coefficients 1 -1 followed by 23 zeros (though the trailing zeros can be omitted).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;However, if you want an estimate of the difference in means, that cannot be provided by the LSMESTIMATE statement. You can see that in the results of the statements you showed by noting that the difference in two means from the LSMEANS statement (the values in the "Mean" column) is not the same as the value (either in the "Estimate" or "Mean" column) from the LSMESTIMATE statement. The Estimate value is the difference in log odds (not means) and the Mean value is nothing useful (the inverse logit of the difference in log odds). To estimate the difference in means, use the &lt;A href="http://support.sas.com/kb/63038" target="_self"&gt;Margins macro&lt;/A&gt; to both fit the model and provide the estimate.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;CODE class=" language-sas"&gt; %Margins(data     = exemple,&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;response = hospital,&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;class    = disease age,&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;model    = disease age disease*age,&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;dist     = binomial,&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;margins  = age,&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;margwhere= age in (1 5),&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;at       = disease,&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;options  = diff cl)&lt;/CODE&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>Tue, 03 Dec 2019 15:52:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/How-to-calculate-difference-of-means-with-interaction-term-using/m-p/609097#M29502</guid>
      <dc:creator>StatDave</dc:creator>
      <dc:date>2019-12-03T15:52:11Z</dc:date>
    </item>
    <item>
      <title>Re: How to calculate difference of means with interaction term using lsmestimate</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/How-to-calculate-difference-of-means-with-interaction-term-using/m-p/609183#M29506</link>
      <description>&lt;P&gt;As &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13633"&gt;@StatDave&lt;/a&gt; notes, Margins (and NLMeans and NLEstimate) are useful macros when the statistical model is a generalized linear model, and not a generalized linear &lt;EM&gt;mixed&lt;/EM&gt; model. (Unfortunately, most of those I work with are mixed.)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 03 Dec 2019 21:18:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/How-to-calculate-difference-of-means-with-interaction-term-using/m-p/609183#M29506</guid>
      <dc:creator>sld</dc:creator>
      <dc:date>2019-12-03T21:18:14Z</dc:date>
    </item>
    <item>
      <title>Re: How to calculate difference of means with interaction term using lsmestimate</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/How-to-calculate-difference-of-means-with-interaction-term-using/m-p/610227#M29542</link>
      <description>&lt;P&gt;Thank you&amp;nbsp;&lt;SPAN&gt;&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13633"&gt;@StatDave&lt;/a&gt;&lt;/SPAN&gt;&lt;SPAN class=""&gt;, and everyone else for the answers. This solution is what i was looking for. However, I am trying to use the Margins macro in sas and it is not working. I entered the code provided and added other covariables that i wanted to adujst for and I got this warning message for both of my main variables. I downloaded the macro from SAS, so i don't know if it ever happened to someone and what they've done to fix it.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class=""&gt;WARNING: No variables found beginning with 'disease_' in data set WORK._MODDAT.&lt;BR /&gt;WARNING: No variables found beginning with 'age_' in data set WORK._MODDAT.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN class=""&gt;Thank you&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 07 Dec 2019 21:46:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/How-to-calculate-difference-of-means-with-interaction-term-using/m-p/610227#M29542</guid>
      <dc:creator>Porscha</dc:creator>
      <dc:date>2019-12-07T21:46:42Z</dc:date>
    </item>
    <item>
      <title>Re: How to calculate difference of means with interaction term using lsmestimate</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/How-to-calculate-difference-of-means-with-interaction-term-using/m-p/612050#M29601</link>
      <description>&lt;P&gt;Please show the exact Margins macro call that caused those errors.&lt;/P&gt;</description>
      <pubDate>Mon, 16 Dec 2019 15:11:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/How-to-calculate-difference-of-means-with-interaction-term-using/m-p/612050#M29601</guid>
      <dc:creator>StatDave</dc:creator>
      <dc:date>2019-12-16T15:11:37Z</dc:date>
    </item>
  </channel>
</rss>

