BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
TheShark
Obsidian | Level 7

Is there a way to suppress the red kernel line when running a proc ttest? My google-fu is coming up short here.

1 ACCEPTED SOLUTION

Accepted Solutions
Rick_SAS
SAS Super FREQ

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; */

View solution in original post

3 REPLIES 3
Rick_SAS
SAS Super FREQ

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; */
TheShark
Obsidian | Level 7

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!

PeterClemmensen
Tourmaline | Level 20

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-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

What is ANOVA?

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.

Discussion stats
  • 3 replies
  • 2664 views
  • 2 likes
  • 3 in conversation