SUPPORT / SAMPLES & SAS NOTES
 

Support

Usage Note 30715: How do I combine the LSMEANS and differences in LSMEANS from Proc MIXED using Proc MIANALYZE?

DetailsAboutRate It

While PROC MIANALYZE cannot directly combine the LSMeans and their differences from PROC MIXED, the LSMEANS table can be sorted differently so that you can use the BY statement in MIANALYZE to read it in.

The following example combines the LSMeans from PROC MIXED. The initial data step creates three multiply-imputed data sets similar to what you would obtain from PROC MI.

   data outmi;
      do _imputation_=1 to 3;
      do trt='test','trt1','trt2';
      do rep=1 to 10;
         trtn+1;
         y=1.3+.86*trtn+rannor(123);
         output;
      end; end; end;
      run;
   
   proc mixed data=outmi;
      by _imputation_;
      class trt;
      model y=trt;
      lsmeans trt;
      ods output lsmeans=lsmeans_ds(drop=effect);
      run;

Once you have created the data set that contains the LSMeans and their standard errors, sort it by TRT and _IMPUTATION_.

   proc sort data=lsmeans_ds;
      by trt _imputation_;
      run;

Now that the data set has been properly sorted, you can run PROC MIANALYZE with the BY statement in order to get the combined LSMeans for each level of TRT.

   proc mianalyze data=lsmeans_ds;
      by trt;
      modeleffects estimate;
      stderr stderr;
      run;

The following statements combine the differences in the LSMeans:

   proc mixed data=outmi;
      by _imputation_;
      class trt;
      model y=trt;
      lsmeans trt/diff;
      ods output diffs=diff;
      run;
   
   data diff2;
      set diff;
      comparison=trt||' vs '||left(_trt);
      run;
   
   proc sort data=diff2;
      by comparison _imputation_;
      run;
   
   proc mianalyze data=diff2;
      by comparison;
      modeleffects estimate;
      stderr stderr;
      run;



Operating System and Release Information

Product FamilyProductSystemSAS Release
ReportedFixed*
SAS SystemSAS/STATz/OS
OpenVMS VAX
Microsoft® Windows® for 64-Bit Itanium-based Systems
Microsoft Windows Server 2003 Datacenter 64-bit Edition
Microsoft Windows Server 2003 Enterprise 64-bit Edition
Microsoft Windows XP 64-bit Edition
Microsoft® Windows® for x64
OS/2
Windows
Microsoft Windows 95/98
Microsoft Windows 2000 Advanced Server
Microsoft Windows 2000 Datacenter Server
Microsoft Windows 2000 Server
Microsoft Windows 2000 Professional
Microsoft Windows NT Workstation
Microsoft Windows Server 2003 Datacenter Edition
Microsoft Windows Server 2003 Enterprise Edition
Microsoft Windows Server 2003 Standard Edition
Microsoft Windows XP Professional
WINDOWS/NTSV
Windows Millennium Edition (Me)
Windows Vista
64-bit Enabled AIX
64-bit Enabled HP-UX
64-bit Enabled Solaris
ABI+ for Intel Architecture
AIX
HP-UX
HP-UX IPF
IRIX
Linux
Linux on Itanium
OpenVMS Alpha
Solaris
Solaris for x64
Tru64 UNIX
* For software releases that are not yet generally available, the Fixed Release is the software release in which the problem is planned to be fixed.