Is there a way to suppress the red kernel line when running a proc ttest? My google-fu is coming up short here.
I don't think you can do that by using the TTEST syntax. I think you would have to modify the underlying template (such as Stat.TTest.Graphics.Summary2 for the two-sample test) and delete (or comment out) the DENSITYPLOT statements that create the kernel curves. For an overview and examples, see the "Template Modification" chapter in the SAS/STAT documentation.
Here's how you can do it for the two-sample t test:
/* redefine template used by PROC TTEST to define summary panel */
proc template;
define statgraph Stat.TTest.Graphics.Summary2;
notes
"Comparative histograms with normal/kernel densities and
boxplots, (two-sample)";
dynamic _Y1 _Y2 _Y _VARNAME _XLAB _SHORTXLAB _CLASS1 _CLASS2
_CLASSNAME _LOGNORMAL _OBSVAR _byline_ _bytitle_
_byfootnote_;
BeginGraph;
entrytitle "Distribution of " _VARNAME;
layout lattice / rows=3 columns=1 columndatarange=
unionall rowweights=(.4 .4 .2) shrinkfonts=true;
columnaxes;
columnaxis / display=(ticks tickvalues label) label
=_XLAB shortlabel=_SHORTXLAB griddisplay=auto_on;
endcolumnaxes;
layout overlay / xaxisopts=(display=none);
histogram _Y1 / binaxis=false primary=true;
if (
(NOT EXISTS(_LOGNORMAL)) AND
(NOT(EXISTS(_PAIRED) AND EXISTS(_RATIO))))
densityplot _Y1 / normal () name="Normal"
legendlabel="Normal" lineattrs=GRAPHFIT;
endif;
/*
densityplot _Y1 / kernel () name="Kernel"
legendlabel="Kernel" lineattrs=GRAPHFIT2;
*/
entry _CLASS1 / autoalign=(topleft topright top);
endlayout;
layout overlay / xaxisopts=(display=none);
histogram _Y2 / binaxis=false primary=true;
if (
(NOT EXISTS(_LOGNORMAL)) AND
(NOT(EXISTS(_PAIRED) AND EXISTS(_RATIO))))
densityplot _Y2 / normal () name="Normal"
legendlabel="Normal" lineattrs=GRAPHFIT;
endif;
/*
densityplot _Y2 / kernel () name="Kernel"
legendlabel="Kernel" lineattrs=GRAPHFIT2;
*/
entry _CLASS2 / autoalign=(topleft topright top);
endlayout;
columnheaders;
layout gridded / shrinkfonts=true;
discreteLegend "Normal" "Kernel" / across=4
BackgroundColor=GraphWalls:Color Opaque=true;
endlayout;
endcolumnheaders;
layout overlay / xaxisopts=(display=none) yaxisopts=(
label=_CLASSNAME reverse=true);
if (EXISTS(_LOGNORMAL))
boxplot X=CLASS Y=_Y / orient=horizontal display
=(caps fill median outliers);
else
boxplot X=CLASS Y=_Y / orient=horizontal;
endif;
endlayout;
columnheaders;
layout gridded / shrinkfonts=true;
discreteLegend "Normal" "Kernel" / across=4
BackgroundColor=GraphWalls:Color Opaque=true;
endlayout;
endcolumnheaders;
endlayout;
if (_BYTITLE_)
entrytitle _BYLINE_ / textattrs=GRAPHVALUETEXT;
else
if (_BYFOOTNOTE_)
entryfootnote halign=left _BYLINE_;
endif;
endif;
EndGraph;
end;
proc ttest data=sashelp.class;
class sex;
var height;
run;
/* to restore the original template, run the following */
/*
proc template;
delete Stat.TTest.Graphics.Summary2 / store=sasuser.templat;
run;
*/
I don't think you can do that by using the TTEST syntax. I think you would have to modify the underlying template (such as Stat.TTest.Graphics.Summary2 for the two-sample test) and delete (or comment out) the DENSITYPLOT statements that create the kernel curves. For an overview and examples, see the "Template Modification" chapter in the SAS/STAT documentation.
Here's how you can do it for the two-sample t test:
/* redefine template used by PROC TTEST to define summary panel */
proc template;
define statgraph Stat.TTest.Graphics.Summary2;
notes
"Comparative histograms with normal/kernel densities and
boxplots, (two-sample)";
dynamic _Y1 _Y2 _Y _VARNAME _XLAB _SHORTXLAB _CLASS1 _CLASS2
_CLASSNAME _LOGNORMAL _OBSVAR _byline_ _bytitle_
_byfootnote_;
BeginGraph;
entrytitle "Distribution of " _VARNAME;
layout lattice / rows=3 columns=1 columndatarange=
unionall rowweights=(.4 .4 .2) shrinkfonts=true;
columnaxes;
columnaxis / display=(ticks tickvalues label) label
=_XLAB shortlabel=_SHORTXLAB griddisplay=auto_on;
endcolumnaxes;
layout overlay / xaxisopts=(display=none);
histogram _Y1 / binaxis=false primary=true;
if (
(NOT EXISTS(_LOGNORMAL)) AND
(NOT(EXISTS(_PAIRED) AND EXISTS(_RATIO))))
densityplot _Y1 / normal () name="Normal"
legendlabel="Normal" lineattrs=GRAPHFIT;
endif;
/*
densityplot _Y1 / kernel () name="Kernel"
legendlabel="Kernel" lineattrs=GRAPHFIT2;
*/
entry _CLASS1 / autoalign=(topleft topright top);
endlayout;
layout overlay / xaxisopts=(display=none);
histogram _Y2 / binaxis=false primary=true;
if (
(NOT EXISTS(_LOGNORMAL)) AND
(NOT(EXISTS(_PAIRED) AND EXISTS(_RATIO))))
densityplot _Y2 / normal () name="Normal"
legendlabel="Normal" lineattrs=GRAPHFIT;
endif;
/*
densityplot _Y2 / kernel () name="Kernel"
legendlabel="Kernel" lineattrs=GRAPHFIT2;
*/
entry _CLASS2 / autoalign=(topleft topright top);
endlayout;
columnheaders;
layout gridded / shrinkfonts=true;
discreteLegend "Normal" "Kernel" / across=4
BackgroundColor=GraphWalls:Color Opaque=true;
endlayout;
endcolumnheaders;
layout overlay / xaxisopts=(display=none) yaxisopts=(
label=_CLASSNAME reverse=true);
if (EXISTS(_LOGNORMAL))
boxplot X=CLASS Y=_Y / orient=horizontal display
=(caps fill median outliers);
else
boxplot X=CLASS Y=_Y / orient=horizontal;
endif;
endlayout;
columnheaders;
layout gridded / shrinkfonts=true;
discreteLegend "Normal" "Kernel" / across=4
BackgroundColor=GraphWalls:Color Opaque=true;
endlayout;
endcolumnheaders;
endlayout;
if (_BYTITLE_)
entrytitle _BYLINE_ / textattrs=GRAPHVALUETEXT;
else
if (_BYFOOTNOTE_)
entryfootnote halign=left _BYLINE_;
endif;
endif;
EndGraph;
end;
proc ttest data=sashelp.class;
class sex;
var height;
run;
/* to restore the original template, run the following */
/*
proc template;
delete Stat.TTest.Graphics.Summary2 / store=sasuser.templat;
run;
*/
Rick,
I finally got around to running this code and it worked like a charm (I knew it would!). I appreciate your help and I'm glad you're actively on the forums and always providing great blog posts!
I assume you are talking about the histogram produced by PROC TTEST. But I don't think so. You can of course edit the template that PROC TTEST uses, though a similar plot is probably easier to create using PROC UNIVARIATE or PROC SGPLOT.
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
ANOVA, or Analysis Of Variance, is used to compare the averages or means of two or more populations to better understand how they differ. Watch this tutorial for more.
Find more tutorials on the SAS Users YouTube channel.