BookmarkSubscribeRSS Feed
NKormanik
Barite | Level 11

From SAS documentation I don't readily perceive a way to turn off the title in BoxPlots.

Can someone please tell me how to do this?

Perhaps there is some program-wide way, as opposed to an option in Proc BoxPlot itself?

Thanks,

Nicholas Kormanik

10 REPLIES 10
AncaTilea
Pyrite | Level 9

Hi,

You have two options - at the very least.

1). turn the ODS graphics off by simply saying:

"ods graphics off" before your plot.

2).Assuming that you use SAS 9.2 or higher (hence you automatically get the ODS Graphics) you can modify the template that is used to render the plot:

proc template;

define statgraph sgdesign;

dynamic _SEX _HEIGHT;

begingraph;

/*  entrytitle halign=center 'Type in your title...';*/

   layout lattice / rowdatarange=data columndatarange=data rowgutter=10 columngutter=10;

      layout overlay;

         boxplot x=_SEX y=_HEIGHT / name='box' boxwidth=0.4 clusterwidth=1.0;

      endlayout;

   endlayout;

endgraph;

end;

run;

proc sgrender data=SASHELP.CLASS template=sgdesign;

dynamic _SEX="SEX" _HEIGHT="HEIGHT";

run;

Hmm, more information is always more helpful.

🙂

Cheers.

Anca.

NKormanik
Barite | Level 11

Once again with SAS, not as simple as "No title, please."

Good grief, why do they make things so difficult.

AncaTilea
Pyrite | Level 9

It will all get easier.

Persistence!

And a bit of patience.

ballardw
Super User

You don't say how the title is being generated. I would try:

title;

before the proc to make sure no title statements are active as a first try.

Otherwise, post the code generating the plot for diagnosis.

NKormanik
Barite | Level 11

Okay, tried that, simply adding title;, and no difference.  Title still there.

By the way, the reason I'd like to get rid of the title is have more room for the graph.

Here is the code that produces the boxplots:

proc boxplot data=nicholas.boxplots;

plot Change*Single /

boxstyle=skeletal

nohlabel

boxconnect=q3

cconnect=blue

boxwidthscale=1

clipfactor=1.5

clipsymbol=dot

;

insetgroup n;

run;

AncaTilea
Pyrite | Level 9

Hi Nicholas.

Sample data could have helped, BUT I still believe that you should try:

ODS GRAPHICS OFF;

TITLE;

....then your code

When I do that there is no title.

Let us know if it works.

Good luck,

Anca.

NKormanik
Barite | Level 11

Thanks Anca.  Correct you are.  However, there are aspects to the ODS graphs that are quite nice, thus I'd like to keep ODS on.

AncaTilea
Pyrite | Level 9

Hi Nicholas.

This is what I figured out so far:

____________________________________________________________________

*this is the code that produces your desired plot;

proc sort data = sashelp.class out = t;by sex;

ods graphics on;

proc boxplot data = t;

plot age*sex /boxstyle=skeletal

                        nohlabel boxconnect=q3

                        cconnect=blue boxwidthscale=1 clipfactor=1.5 clipsymbol=dot;

                        insetgroup n;

run;quit;

____________________________________________________________________

OK, so in order to keep the nice features that ODS Graphics provides, but to remove the title, I think you may need to change from PROC BOXPLOT to PROC TEMPLATE + PROC SGRENDER.

So, the one way I figured how to remove the title is by "defining" your own template where you don't use the "ENTRYTITLE" statement (See below, please):

proc template;

define statgraph PrettyBox;

begingraph;

    *entrytitle 'Distribution of Age by Sex';*<----This statement makes your title appear, by default, when you use the ODS GRAPHICS;

        layout overlay;

            boxplot y=age x=sex;

        endlayout;

endgraph;

end;

run;

proc sort data=sashelp.class out=class;by sex;run;

proc sgrender data=class template=PrettyBox;

run;

However, you will need to read about how to "enhance" the graph template definition (which I called "prettyBox") to add the Ns, and the different widths, and all these other things that we both know how to do in PROC BOXPLOT.

OK.

I may return if I come up with a better answer.

:smileyconfused:

WEST
Calcite | Level 5

You want to turn title off... I want to turn it on.  how do i turn on titles on.  Please be patient.  i am a basic user.  i dont know where to

turn the ODS graphics off by simply saying:

"ods graphics off" before your plot.

where do i say this?  can i just say ods graphics on?  using JMP11

AncaTilea
Pyrite | Level 9

Hi.

I don't use JMP, but it would help to repost the question as a separate discussion under JMP.

Not sure if you can use title statements in JMP, but if yes, then you can add something like

title "your title";

proc to make the plot;

title;

Good luck,

Anca.

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 10 replies
  • 7000 views
  • 4 likes
  • 4 in conversation