<?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 mixed constrast statement how to use specific examples in Statistical Procedures</title>
    <link>https://communities.sas.com/t5/Statistical-Procedures/Proc-mixed-constrast-statement-how-to-use-specific-examples/m-p/989676#M49477</link>
    <description>Here is an example how to write ESTIMATE for PROC MIXED if you want to compare random effect.&lt;BR /&gt;&lt;BR /&gt;&lt;A href="https://sas.service-now.com/csm/en/obtaining-subject-specific-parameter-estimates-and-tests-for-a-random?id=kb_article_view&amp;amp;sysparm_article=KB0057270" target="_blank"&gt;https://sas.service-now.com/csm/en/obtaining-subject-specific-parameter-estimates-and-tests-for-a-random?id=kb_article_view&amp;amp;sysparm_article=KB0057270&lt;/A&gt;</description>
    <pubDate>Tue, 16 Jun 2026 06:23:46 GMT</pubDate>
    <dc:creator>Ksharp</dc:creator>
    <dc:date>2026-06-16T06:23:46Z</dc:date>
    <item>
      <title>Proc mixed constrast statement how to use specific examples</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Proc-mixed-constrast-statement-how-to-use-specific-examples/m-p/989664#M49475</link>
      <description>&lt;P&gt;I am unable to write valid contrasts for 2-way interactions and higher. Everything i write is not estimable, the assessment of which is unknown to me.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Let factor A be (0,1),&amp;nbsp;&amp;nbsp;factor B be (0,1),&amp;nbsp;factor C be (1,2,3,4)&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;1) I want to contrast factor B at factor A=1.&lt;/P&gt;&lt;P&gt;&amp;nbsp;I write: contrast 'factor B at A=1' what do i write next and&amp;nbsp; WHY?&amp;nbsp;&lt;/P&gt;&lt;P&gt;2) I want to contrast factor C levels 1,2 vs 3&amp;nbsp; vs 4&amp;nbsp;at factor B levels B=0&lt;/P&gt;&lt;P&gt;Again, what do i write and why?&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to emphasize that i don't want a reply of what Contrast does. I've read the&amp;nbsp; help statement several times and it's not&amp;nbsp; usefully helpful to me.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks, Gene Maguin&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;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 15 Jun 2026 20:56:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Proc-mixed-constrast-statement-how-to-use-specific-examples/m-p/989664#M49475</guid>
      <dc:creator>emaguin</dc:creator>
      <dc:date>2026-06-15T20:56:28Z</dc:date>
    </item>
    <item>
      <title>Re: Proc mixed constrast statement how to use specific examples</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Proc-mixed-constrast-statement-how-to-use-specific-examples/m-p/989666#M49476</link>
      <description>&lt;P&gt;You should avoid the use of CONTRAST or ESTIMATE statements for simple comparisons of means by using alternative statements like LSMEANS, SLICE, or LSMESTIMATE. These statements simplify or remove the necessity of correctly providing estimable functions of model parameters. All of these statements are illustrated and compared in multiple examples in &lt;A href="http://support.sas.com/kb/24447" target="_self"&gt;this note&lt;/A&gt;. As shown there, the SLICE statement can be used to compare levels of one variable at each level of another variable. For example, when the model contains the A*B interaction, this statement compares the levels of A at each level of B, where both A and B are CLASS variables:&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; slice a*b / sliceby=b;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Or you could use LSMEANS:&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; lsmeans a*b / slice=b;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you add the E option in either statement, you will get a table showing the coefficients on the model parameters that you could use in a CONTRAST or ESTIMATE statement to produce the same results.&lt;/P&gt;</description>
      <pubDate>Tue, 16 Jun 2026 02:08:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Proc-mixed-constrast-statement-how-to-use-specific-examples/m-p/989666#M49476</guid>
      <dc:creator>StatDave</dc:creator>
      <dc:date>2026-06-16T02:08:13Z</dc:date>
    </item>
    <item>
      <title>Re: Proc mixed constrast statement how to use specific examples</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Proc-mixed-constrast-statement-how-to-use-specific-examples/m-p/989676#M49477</link>
      <description>Here is an example how to write ESTIMATE for PROC MIXED if you want to compare random effect.&lt;BR /&gt;&lt;BR /&gt;&lt;A href="https://sas.service-now.com/csm/en/obtaining-subject-specific-parameter-estimates-and-tests-for-a-random?id=kb_article_view&amp;amp;sysparm_article=KB0057270" target="_blank"&gt;https://sas.service-now.com/csm/en/obtaining-subject-specific-parameter-estimates-and-tests-for-a-random?id=kb_article_view&amp;amp;sysparm_article=KB0057270&lt;/A&gt;</description>
      <pubDate>Tue, 16 Jun 2026 06:23:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Proc-mixed-constrast-statement-how-to-use-specific-examples/m-p/989676#M49477</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2026-06-16T06:23:46Z</dc:date>
    </item>
    <item>
      <title>Re: Proc mixed constrast statement how to use specific examples</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Proc-mixed-constrast-statement-how-to-use-specific-examples/m-p/989720#M49478</link>
      <description>&lt;P&gt;Like what&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13633"&gt;@StatDave&lt;/a&gt;&amp;nbsp;says, there are better ways to do the contrasts you listed, like the LSMEANS, SLICE, LSMESTIMATE statements. But if you still want the syntax for the CONTRAST statement, here are some examples.&lt;/P&gt;
&lt;P&gt;Suppose your model is&lt;/P&gt;
&lt;P&gt;class A B C;&lt;/P&gt;
&lt;P&gt;model y=A B C A*B A*C B*C;&amp;nbsp;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;where factor A (0,1),&amp;nbsp;&amp;nbsp;factor B (0,1),&amp;nbsp;factor C (1,2,3,4)&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;Then here is the contrast statement:&lt;/P&gt;
&lt;P&gt;contrast "b 0 vs 1 at A=1'&amp;nbsp; B 1 -1 A*B 0 0 1 -1;&lt;/P&gt;
&lt;P&gt;Note that&lt;/P&gt;
&lt;P&gt;1. The order of the coefficients depends on the order of the levels of your CLASS variables, as well as the CLASS statement. For example, CLASS A B C; determines that the coefficients for the interaction term, whether you use A*B or B*A, would be A0B0, A0B1, A1B0, A1B1 (hold the first effect's level, loop through the second effect's levels, then move on).&lt;/P&gt;
&lt;P&gt;3. you could start with two simple estimates first: estimate "b0 at A=1" intercept 1 A 0 1 B 1 0 A*B 0 0 1 0; and&lt;/P&gt;
&lt;P&gt;estimate "b1 at A=1" intercept 1 A 0 1 B 0 1 A*B 0 0 0 1;&lt;/P&gt;
&lt;P&gt;then take the difference of the corresponding coefficients, to get the CONTRAST statement above.&lt;/P&gt;
&lt;P&gt;Similarly, you might specify:&lt;/P&gt;
&lt;P&gt;contrast "C 1 vs 3 at B=0" C 1 0 -1 0 B*C&amp;nbsp; 1 0 -1 0 0 0 0 0;&lt;/P&gt;
&lt;P&gt;contrast "C1 vs 4 at B=0" C 1 0 0 -1 B*C 1 0 0 -1 0 0 0 0;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I trust you understand that when I specify C 1 0 0 -1, that is because C has 4 levels, and the coefficients for these four levels are 1 (for level 1), 0 (for level 2), 0 (for level 3), and -1 (for level 4). So essentially it is comparing level 1 and level 4. I hope it make sense.&lt;/P&gt;
&lt;P&gt;Like&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13633"&gt;@StatDave&lt;/a&gt;&amp;nbsp;pointed out, if you add the E option in in the LSMEANS or LSMESTIMATE statements, that would help you come up with the CONTRAST/ESTIMATE statement. Similarly, you can always add the E option in the CONTRAST and ESTIMATE statement to help you understand the coefficients in these statements.&lt;/P&gt;
&lt;P&gt;Hope this helps,&lt;/P&gt;
&lt;P&gt;Jill&lt;/P&gt;</description>
      <pubDate>Tue, 16 Jun 2026 19:14:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Proc-mixed-constrast-statement-how-to-use-specific-examples/m-p/989720#M49478</guid>
      <dc:creator>jiltao</dc:creator>
      <dc:date>2026-06-16T19:14:50Z</dc:date>
    </item>
  </channel>
</rss>

