<?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 reverse the value of difference of lsmeans -1.0(2.00)  &amp;lt;b-a&amp;gt; instead of 1.0(2.00) &amp;amp; in Statistical Procedures</title>
    <link>https://communities.sas.com/t5/Statistical-Procedures/how-to-reverse-the-value-of-difference-of-lsmeans-1-0-2-00-lt-b/m-p/632839#M30329</link>
    <description>&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="捕获.JPG" style="width: 556px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/36950i5B8CDECFA021E550/image-size/large?v=v2&amp;amp;px=999" role="button" title="捕获.JPG" alt="捕获.JPG" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;hi Dave, two options don't work in proc glm.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can take a look at my code as below:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;*******************************
date and time: Tuesday, November 05, 2019 17:09:46
stat user's guide
http://documentation.sas.com/?docsetId=statug&amp;amp;docsetTarget=statug_glm_syntax10.htm&amp;amp;docsetVersion=15.1&amp;amp;locale=zh-CN
*dependent variable: height
*fixed factors(class/group var): sex 
*covariate:weight 

ANCOVA Analysis		
ABC material			               trt1			    trt2
LS Means (SE)	                  xx.x (xx.xx)	       xx.x (xx.xx)
95% CI	                                (xx.xx, xx.xx)	      (xx.xx, xx.xx)

Diff LS Means (SE)	C	            xx.x (xx.xx)
95% C.I.		                         (xx.xx, xx.xx)

*******************************;

ods output  OverallANOVA=Overall  ModelANOVA=stat LSMeans=LSMeans 
LSMeanCL=LSMeanCL  LSMeanDiffCL=LSMeanDiffCL  FitStatistics=FitStatistics diff=adiff Estimates=estdiffs    
;

;
proc glm data=sashelp.class;
	class sex;
	model height=weight sex;
	lsmeans sex/pdiff cl stderr;
	estimate 'male vs female' sex  1 -1 ;
run;
quit;


/*LS Means (SE) 95% CI*/
data lsm;
    length mean_se cl $200;
	merge LSMeans LSMeanCL ;
	by sex;
	mean_se= strip(put(LSMean,18.2-L))||" ("||strip(put(stderr,18.2-L))||")";
	cl="("||strip(put(lowercl,18.2-L))||","||strip(put(uppercl,18.2-L))||")";
run;

proc transpose data=lsm out=lsm1(rename=(f=col1 m=col2));
	id sex;
	var mean_se cl;
run;

/*Diff LS Means (SE)2*/
data dlsm;
    length dmean_se dcl $200;
	merge LSMeanDiffCL estdiffs ;
	by dependent;
	dmean_se= strip(put(difference,18.2-L))||" ("||strip(put(stderr,18.2-L))||")";
	dcl="("||strip(put(lowercl,18.2-L))||","||strip(put(uppercl,18.2-L))||")";
run;

proc transpose data=dlsm out=dlsm1(rename=(col1=col2));
	var dmean_se dcl;
run;

data trans;
	set lsm1 dlsm1;
run;

&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="捕获.JPG" style="width: 556px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/36949i63F1E76B92CA16E9/image-size/large?v=v2&amp;amp;px=999" role="button" title="捕获.JPG" alt="捕获.JPG" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
    <pubDate>Wed, 18 Mar 2020 02:22:22 GMT</pubDate>
    <dc:creator>blueskyxyz</dc:creator>
    <dc:date>2020-03-18T02:22:22Z</dc:date>
    <item>
      <title>how to reverse the value of difference of lsmeans -1.0(2.00)  &lt;b-a&gt; instead of 1.0(2.00) &lt;a-b&gt;?</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/how-to-reverse-the-value-of-difference-of-lsmeans-1-0-2-00-lt-b/m-p/632594#M30318</link>
      <description>&lt;TABLE width="221"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD width="73"&gt;　&lt;/TD&gt;
&lt;TD width="49"&gt;TRTA&lt;/TD&gt;
&lt;TD width="51"&gt;TRTB&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="73"&gt;LS Mean (SE)&lt;/TD&gt;
&lt;TD width="49"&gt;6.5(1.70)&lt;/TD&gt;
&lt;TD width="51"&gt;5.0(2.50)&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="73"&gt;&lt;SPAN&gt;Difference (SE)&lt;/SPAN&gt;&lt;/TD&gt;
&lt;TD width="49"&gt;　&lt;/TD&gt;
&lt;TD width="51"&gt;-1.0(2.00)&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="73"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD width="49"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD width="51"&gt;TRTB-TRTA&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;take an example, I want to get the value&amp;nbsp; -1.0(2.00)&amp;nbsp;&amp;nbsp;&amp;lt;trtb-trta&amp;gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;instead of 1.0(2.00) &amp;lt;trta-trtb&amp;gt;, how to change my code in anova analysis?&lt;/P&gt;</description>
      <pubDate>Tue, 17 Mar 2020 08:45:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/how-to-reverse-the-value-of-difference-of-lsmeans-1-0-2-00-lt-b/m-p/632594#M30318</guid>
      <dc:creator>blueskyxyz</dc:creator>
      <dc:date>2020-03-17T08:45:45Z</dc:date>
    </item>
    <item>
      <title>Re: how to reverse the value of difference of lsmeans -1.0(2.00)  &lt;b-a&gt; instead of 1.0(2.00) &amp;</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/how-to-reverse-the-value-of-difference-of-lsmeans-1-0-2-00-lt-b/m-p/632612#M30319</link>
      <description>&lt;P&gt;What SAS PROC are you using?&lt;/P&gt;</description>
      <pubDate>Tue, 17 Mar 2020 10:57:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/how-to-reverse-the-value-of-difference-of-lsmeans-1-0-2-00-lt-b/m-p/632612#M30319</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2020-03-17T10:57:38Z</dc:date>
    </item>
    <item>
      <title>Re: how to reverse the value of difference of lsmeans -1.0(2.00)  &lt;b-a&gt; instead of 1.0(2.00) &amp;</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/how-to-reverse-the-value-of-difference-of-lsmeans-1-0-2-00-lt-b/m-p/632663#M30322</link>
      <description>&lt;P&gt;You should be able to reverse the difference by using an option for the variable in the CLASS statement - such as DESCENDING or ORDER=. For example, for variable B:&amp;nbsp; class a b(desc) c;&lt;/P&gt;</description>
      <pubDate>Tue, 17 Mar 2020 13:41:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/how-to-reverse-the-value-of-difference-of-lsmeans-1-0-2-00-lt-b/m-p/632663#M30322</guid>
      <dc:creator>StatDave</dc:creator>
      <dc:date>2020-03-17T13:41:44Z</dc:date>
    </item>
    <item>
      <title>Re: how to reverse the value of difference of lsmeans -1.0(2.00)  &lt;b-a&gt; instead of 1.0(2.00) &amp;</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/how-to-reverse-the-value-of-difference-of-lsmeans-1-0-2-00-lt-b/m-p/632838#M30328</link>
      <description>Hi Miller,  I use proc glm since the result needs to output LS Means (SE) &amp;amp; Diff LS Means (SE) with ANCOVA Analysis.</description>
      <pubDate>Wed, 18 Mar 2020 02:07:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/how-to-reverse-the-value-of-difference-of-lsmeans-1-0-2-00-lt-b/m-p/632838#M30328</guid>
      <dc:creator>blueskyxyz</dc:creator>
      <dc:date>2020-03-18T02:07:46Z</dc:date>
    </item>
    <item>
      <title>Re: how to reverse the value of difference of lsmeans -1.0(2.00)  &lt;b-a&gt; instead of 1.0(2.00) &amp;</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/how-to-reverse-the-value-of-difference-of-lsmeans-1-0-2-00-lt-b/m-p/632839#M30329</link>
      <description>&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="捕获.JPG" style="width: 556px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/36950i5B8CDECFA021E550/image-size/large?v=v2&amp;amp;px=999" role="button" title="捕获.JPG" alt="捕获.JPG" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;hi Dave, two options don't work in proc glm.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can take a look at my code as below:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;*******************************
date and time: Tuesday, November 05, 2019 17:09:46
stat user's guide
http://documentation.sas.com/?docsetId=statug&amp;amp;docsetTarget=statug_glm_syntax10.htm&amp;amp;docsetVersion=15.1&amp;amp;locale=zh-CN
*dependent variable: height
*fixed factors(class/group var): sex 
*covariate:weight 

ANCOVA Analysis		
ABC material			               trt1			    trt2
LS Means (SE)	                  xx.x (xx.xx)	       xx.x (xx.xx)
95% CI	                                (xx.xx, xx.xx)	      (xx.xx, xx.xx)

Diff LS Means (SE)	C	            xx.x (xx.xx)
95% C.I.		                         (xx.xx, xx.xx)

*******************************;

ods output  OverallANOVA=Overall  ModelANOVA=stat LSMeans=LSMeans 
LSMeanCL=LSMeanCL  LSMeanDiffCL=LSMeanDiffCL  FitStatistics=FitStatistics diff=adiff Estimates=estdiffs    
;

;
proc glm data=sashelp.class;
	class sex;
	model height=weight sex;
	lsmeans sex/pdiff cl stderr;
	estimate 'male vs female' sex  1 -1 ;
run;
quit;


/*LS Means (SE) 95% CI*/
data lsm;
    length mean_se cl $200;
	merge LSMeans LSMeanCL ;
	by sex;
	mean_se= strip(put(LSMean,18.2-L))||" ("||strip(put(stderr,18.2-L))||")";
	cl="("||strip(put(lowercl,18.2-L))||","||strip(put(uppercl,18.2-L))||")";
run;

proc transpose data=lsm out=lsm1(rename=(f=col1 m=col2));
	id sex;
	var mean_se cl;
run;

/*Diff LS Means (SE)2*/
data dlsm;
    length dmean_se dcl $200;
	merge LSMeanDiffCL estdiffs ;
	by dependent;
	dmean_se= strip(put(difference,18.2-L))||" ("||strip(put(stderr,18.2-L))||")";
	dcl="("||strip(put(lowercl,18.2-L))||","||strip(put(uppercl,18.2-L))||")";
run;

proc transpose data=dlsm out=dlsm1(rename=(col1=col2));
	var dmean_se dcl;
run;

data trans;
	set lsm1 dlsm1;
run;

&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="捕获.JPG" style="width: 556px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/36949i63F1E76B92CA16E9/image-size/large?v=v2&amp;amp;px=999" role="button" title="捕获.JPG" alt="捕获.JPG" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 18 Mar 2020 02:22:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/how-to-reverse-the-value-of-difference-of-lsmeans-1-0-2-00-lt-b/m-p/632839#M30329</guid>
      <dc:creator>blueskyxyz</dc:creator>
      <dc:date>2020-03-18T02:22:22Z</dc:date>
    </item>
    <item>
      <title>Re: how to reverse the value of difference of lsmeans -1.0(2.00)  &lt;b-a&gt; instead of 1.0(2.00) &amp;</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/how-to-reverse-the-value-of-difference-of-lsmeans-1-0-2-00-lt-b/m-p/632919#M30330</link>
      <description>&lt;P&gt;If you are creating this table via DATA steps, then simply multiplying the value by –1 takes care of the issue.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In this simple example, you can also do this in PROC GLM via&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;estimate 'male vs female' sex  -1 1 ;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;This should work because this is a very simple model, but in more complicated cases, ESTIMATE does not produce LS Means unless you specifically construct an estimate statement to have the coefficients for the LS Mean (which is explained &lt;A href="https://documentation.sas.com/?docsetId=statug&amp;amp;docsetTarget=statug_glm_details41.htm&amp;amp;docsetVersion=14.3&amp;amp;locale=en" target="_self"&gt;here&lt;/A&gt;, and which you can determine via the E3 option in the model statement). In these more complicated cases, I wouldn't bother myself in trying to construct and type in the proper ESTIMATE statement, I would rather multiply the result by –1, which I can do in my head a lot faster than I can type in the proper ESTIMATE statement.&lt;/P&gt;</description>
      <pubDate>Wed, 18 Mar 2020 11:39:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/how-to-reverse-the-value-of-difference-of-lsmeans-1-0-2-00-lt-b/m-p/632919#M30330</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2020-03-18T11:39:27Z</dc:date>
    </item>
    <item>
      <title>Re: how to reverse the value of difference of lsmeans -1.0(2.00)  &lt;b-a&gt; instead of 1.0(2.00) &amp;</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/how-to-reverse-the-value-of-difference-of-lsmeans-1-0-2-00-lt-b/m-p/633067#M30335</link>
      <description>&lt;P&gt;If you switch to a procedure like PROC GENMOD to fit your model, you could use the DESCENDING option in the CLASS statement.&lt;/P&gt;</description>
      <pubDate>Wed, 18 Mar 2020 19:49:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/how-to-reverse-the-value-of-difference-of-lsmeans-1-0-2-00-lt-b/m-p/633067#M30335</guid>
      <dc:creator>StatDave</dc:creator>
      <dc:date>2020-03-18T19:49:47Z</dc:date>
    </item>
  </channel>
</rss>

