A plot summarizing the differences among LS-means is produced by the PLOTS=DIFFPLOT option in the LSMEANS statement. This plot is known as the mean-mean scatter plot. Limited aspects of the plot can be specified using suboptions. Most modifications to the appearance of the produced plot must be made using one of the general methods for altering ODS graphs discussed in this note. The following shows how this plot can be redrawn to show only the significant differences among LS-means. This can be particularly helpful when there are many differences which produces a crowded plot.
Note that the table of differences produced by the LSMEANS statement can easily be subsetted to display only the significant differences using PROC PLM. This is done by using the STORE statement in the analysis procedure to save the fitted model and then using both the FILTER and LSMEANS statements in PROC PLM. However, this method does not work to subset the results shown in the mean-mean scatter plot.
The following uses example data presented in the PROC GLM documentation. Of interest are the differences among the four drugs. The PROC GENMOD statements fit the model and then save it using the STORE statement. PROC PLM is then used to do the LS-means analysis. The LSMEANS statement is specified along with the PLOTS=DIFFPLOT and CL options to produce the mean-mean scatter plot. The FILTER statement examines the table of differences and retains only those differences that are significant at the 0.05 level. The LSMEANS statement is also included in the GENMOD step to show the default table of all LS-means differences.
data a; input drug disease @; do i=1 to 6; input y @; output; end; datalines; 1 1 42 44 36 13 19 22 1 2 33 . 26 . 33 21 1 3 31 -3 . 25 25 24 2 1 28 . 23 34 42 13 2 2 . 34 33 31 . 36 2 3 3 26 28 32 4 16 3 1 . . 1 29 . 19 3 2 . 11 9 7 1 -6 3 3 21 1 . 9 3 . 4 1 24 . 9 22 -2 15 4 2 27 12 12 -5 16 15 4 3 22 7 25 5 12 . ; proc genmod data=a; class drug disease; model y=drug disease drug*disease; lsmeans drug / pdiff; ods output diffplot=Diffs; store gen; run; proc plm restore=gen; lsmeans drug / pdiff plots=diffplot cl; filter probt<.05; run;
The first table is from the LSMEANS statement in the GENMOD step and shows all six pairwise LS-means differences. The second table shows only the four LS-means differences that are significant at the 0.05 level as required by the FILTER statement. However, the mean-mean scatter plot as produced by the LSMEANS statement either in the GENMOD or PLM step shows all six differences.
|
To redraw the mean-mean scatter plot showing only the significant differences, it is necessary to save the data that produces the plot and then use PROC SGPLOT to produce the desired plot. In the PROC GENMOD step above, an ODS OUTPUT statement is specified to save the plot data in data set Diffs. Note that the name of the plot is needed for this statement. The name of the mean-mean scatter plot, DiffPlot, can be found in the documentation of the LSMEANS statement.
The following PROC SGPLOT statements produce the desired graph using the saved graph data. You might want to display the contents of the Diffs data set to see the variables that are used in the code below.
The ASPECT=1 option produces a square plot since the axes use the same range of values. The NOAUTOLEGEND option turns off the legend that appears by default in the plot produced by the LSMEANS statement as seen above. The legend is not needed since only significant differences are to be shown. The WHERE statement removes the observations in the graph data for the nonsignificant differences. The REG statement plots the line segments that represent the confidence intervals for the differences. Marker symbols are removed and a color is also specified. The REFLINE statements draw semi-transparent lines at the values of the LS-means and labels them with the associated drug numbers. The LINEPARM statement draws the dashed, semi-transparent, diagonal reference line. The YAXIS and XAXIS statements set the range for each axis and add a small offset, within in the plot area, outside the specified range. Finally, a suitable title is specified to display above the plot.
proc sgplot data=Diffs aspect=1 noautolegend; where group ne 'Not significant'; reg y=lsm_ x=lsm / group=id_comp nomarkers lineattrs=(color=red); refline lsm1 / axis=x label=level labelloc=inside labelpos=min transparency=.5 lineattrs=(color=lightgrey); refline lsm1 / axis=y label=level labelloc=inside transparency=.5 lineattrs=(color=lightgrey); lineparm x=5 y=5 slope=1 / transparency=.3 lineattrs=(color=grey pattern=mediumdash); yaxis min=5 max=30 display=(nolabel) offsetmin=.05 offsetmax=.05; xaxis min=5 max=30 display=(nolabel) offsetmin=.05 offsetmax=.05; title "Significant drug differences"; run;
The plot produced by the above code is shown below. Note that it closely resembles the general appearance of the plot produced by the LSMEANS statement.
Product Family | Product | System | SAS Release | |
Reported | Fixed* | |||
SAS System | N/A | Microsoft Windows XP 64-bit Edition | ||
Microsoft® Windows® for x64 | ||||
Microsoft Windows Server 2003 Enterprise 64-bit Edition | ||||
Microsoft Windows Server 2003 Datacenter 64-bit Edition | ||||
Microsoft® Windows® for 64-Bit Itanium-based Systems | ||||
Microsoft Windows Server 2012 R2 Datacenter | ||||
Microsoft Windows Server 2012 R2 Std | ||||
Microsoft Windows Server 2008 R2 | ||||
Microsoft Windows 8 Pro x64 | ||||
Microsoft Windows 8 x64 | ||||
Microsoft Windows 8 Pro 32-bit | ||||
Microsoft Windows 8 Enterprise x64 | ||||
Microsoft Windows 7 | ||||
Microsoft Windows 8 Enterprise 32-bit | ||||
Microsoft Windows 10 | ||||
Macintosh | ||||
Macintosh on x64 | ||||
Chrome Web Browser | ||||
Apple Mobile Operating System | ||||
Android Operating System | ||||
OpenVMS VAX | ||||
N/A | ||||
z/OS 64-bit | ||||
IBM AS/400 | ||||
z/OS | ||||
Solaris for x64 | ||||
Tru64 UNIX | ||||
Solaris | ||||
OpenVMS Alpha | ||||
OpenVMS on HP Integrity | ||||
Linux on Itanium | ||||
Linux for AArch64 | ||||
Linux for x64 | ||||
IRIX | ||||
Linux | ||||
HP-UX IPF | ||||
AIX | ||||
HP-UX | ||||
ABI+ for Intel Architecture | ||||
64-bit Enabled HP-UX | ||||
64-bit Enabled Solaris | ||||
64-bit Enabled AIX | ||||
Teradata on Linux | ||||
Cloud Foundry | ||||
Netezza TwinFin 64-bit SMP Hosts | ||||
Netezza TwinFin 64-bit S-Blades | ||||
Netezza TwinFin 32-bit SMP Hosts | ||||
Netezza TwinFin 32bit blade | ||||
DB2 Universal Database on Linux x64 | ||||
DB2 Universal Database on AIX | ||||
Aster Data nCluster on Linux x64 | ||||
OS/2 | ||||
SAS Cloud | ||||
Microsoft Windows 8.1 Enterprise 32-bit | ||||
Microsoft Windows 8.1 Enterprise x64 | ||||
Microsoft Windows 8.1 Pro 32-bit | ||||
Microsoft Windows 8.1 Pro x64 | ||||
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 Server 2003 for x64 | ||||
Microsoft Windows Server 2008 | ||||
Microsoft Windows Server 2008 for x64 | ||||
Microsoft Windows Server 2012 Datacenter | ||||
Microsoft Windows Server 2012 Std | ||||
Microsoft Windows Server 2016 | ||||
Microsoft Windows Server 2019 | ||||
Microsoft Windows XP Professional | ||||
Windows 7 Enterprise 32 bit | ||||
Windows 7 Enterprise x64 | ||||
Windows 7 Home Premium 32 bit | ||||
Windows 7 Home Premium x64 | ||||
Windows 7 Professional 32 bit | ||||
Windows 7 Professional x64 | ||||
Windows 7 Ultimate 32 bit | ||||
Windows 7 Ultimate x64 | ||||
Windows Millennium Edition (Me) | ||||
Windows Vista | ||||
Windows Vista for x64 |
Type: | Usage Note |
Priority: | |
Topic: | Analytics ==> Statistical Graphics SAS Reference ==> Procedures ==> GEE SAS Reference ==> Procedures ==> GENMOD SAS Reference ==> Procedures ==> GLIMMIX SAS Reference ==> Procedures ==> GLM SAS Reference ==> Procedures ==> LIFEREG SAS Reference ==> Procedures ==> LOGISTIC SAS Reference ==> Procedures ==> MIXED SAS Reference ==> Procedures ==> ORTHOREG SAS Reference ==> Procedures ==> PHREG SAS Reference ==> Procedures ==> PLM SAS Reference ==> Procedures ==> PROBIT SAS Reference ==> Procedures ==> SURVEYLOGISTIC SAS Reference ==> Procedures ==> SURVEYPHREG SAS Reference ==> Procedures ==> SURVEYREG |
Date Modified: | 2020-02-27 16:48:02 |
Date Created: | 2020-02-26 15:18:57 |