SUPPORT / SAMPLES & SAS NOTES
 

Support

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

DetailsAboutRate It

While PROC MIANALYZE cannot directly combine the LSMeans and their differences from PROC GLM, 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 GLM. 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 glm data=outmi;
      by _imputation_;
      class trt;
      model y=trt;
      lsmeans trt/stderr;
      ods select lsmeans;
      ods output lsmeans=lsmeans_ds;
      run;
      quit;
      

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 lsmean;
      stderr stderr;
      run;

Unfortunately, since PROC GLM does not report a standard error for the difference of two LSMeans, GLM cannot be used in conjunction with MIANALYZE. You will need to write the equivalent code in PROC MIXED and follow this example. If your PROC GLM code is

   proc glm data=outmi;
      by _imputation_;
      class trt;
      model y=trt;
      lsmeans trt/pdiff;
      run;
      quit;

then the equivalent PROC MIXED code is:

   proc mixed data=outmi;
      by _imputation_;
      class trt;
      model y=trt;
      lsmeans trt/diff;
      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.