DATA Step, Macro, Functions and more

Graph Title Not Showing Up

Reply
Contributor
Posts: 39

Graph Title Not Showing Up

[ Edited ]

Any time I export/copy and paste/do anything to do with a graph, the title does NOT go with it. 

 

Below is what happens:

 

blah.png

 

 

 

 

And here is what I want with the title "Total Loaded Mileage" at the top.

Capture.JPG

 

Here is a sample of my code:

goptions htext=15pt;

title h=15pt "Total Loaded Mileage on CN";

proc sgplot data=work.mileage_by_year;

vbar service_year / response=per_mil barwidth=.25 fillattrs=(color=firebrick) nooutline;

xaxis valueattrs=(size=12pt) label="Year" labelattrs=(size=12pt) ;

yaxis valueattrs=(size=12pt) label="Miles in Millions" grid labelattrs=(size=12pt) values=(0 to 2500 by 500);

run;

title;

 

Why isn't the title showing up?

SAS Super FREQ
Posts: 683

Re: Graph Title Not Showing Up

Hi

 

You have to tell the ODS destination to add the title into the image. How you do this depends on the GUI you are using.

 

But it ends with code similar to the one below. The GTITLE option tells SAS to add the title to the graph

ods html file="c:\temp\with_title.html" gtitle;

title "Some Graph";
proc sgplot data=sashelp.cars;
  vbar type / group=origin;
run;
ods html close;

Bruno

Contributor
Posts: 39

Re: Graph Title Not Showing Up

i tried this and it didn't work Smiley Sad.  the html output had no title.

Super User
Posts: 17,826

Re: Graph Title Not Showing Up

Post your full code and log please. 

Specify gpath on the html statement as well. 

 

 

Contributor
Posts: 39

Re: Graph Title Not Showing Up

This is my code from the log with the info on when it was run:

 

 

data work.mileage_by_year;

set work.mileage_by_year;

per_mil=sum_of_loaded_miles/1000000;

run;

 

NOTE: There were 10 observations read from the data set WORK.MILEAGE_BY_YEAR.

NOTE: The data set WORK.MILEAGE_BY_YEAR has 10 observations and 3 variables.

NOTE: DATA statement used (Total process time):

real time 0.01 seconds

cpu time 0.00 seconds

 

3 The SAS System 10:04 Tuesday, April 19, 2016

 

 

 

 

ods html path="C:\Users"

gpath="C:\Users\png"

file= "test.htm" gtitle;

NOTE: Writing HTML Body file: test.htm

ERROR: Insufficient authorization to access C:\Users\test.htm.

ERROR: No body file. HTML output will not be created.

goptions htext=15pt;

title h=15pt "Total Loaded Mileage on CN";

proc sgplot data=work.mileage_by_year;

vbar service_year / response=per_mil barwidth=.25 fillattrs=(color=firebrick) nooutline;

xaxis valueattrs=(size=12pt) label="Year" labelattrs=(size=12pt) ;

yaxis valueattrs=(size=12pt) label="Miles in Millions" grid labelattrs=(size=12pt) values=(0 to 2500 by 500);

run;

 

Super User
Posts: 17,826

Re: Graph Title Not Showing Up

Fix the error in your code first. 

Point it to a path you have access to, most likely a place on server. Or just remove file option and it will default to a location that works. 

Contributor
Posts: 39

Re: Graph Title Not Showing Up

[ Edited ]

I'm so sorry, I'm having a really hard time explaining myself.  I want to 'resubmit' a picture to help explain the issue i'm having. 

 

I want to just copy a graph output in SAS, and paste it into any word program.  However, I can only copy the graph, not the title because it's "outside" the graph box.  How do I get the title "inside" the graph box so it all copies as one item?

 

This first image below is what it normally outputs in the results window:

 

blah1.JPG

 

This second image is what I want, where the title is IN the larger border box for the graph (in the circled red space):

blah2.png

 

It seems like every graph I see online for SAS automatically is in the format I'm wanting to get, yet uses the same methodology with using the title statement in the code.

 

Again, I apologize as I'm better at showing things than explaining and hopefully someone can understand my crazy brain.

 

Edit:  here's a random graph I found online from a sas tutorial

blah3.JPG

how does one get the title "Increase of Height with Age" INSIDE the box??

Super User
Posts: 17,826

Re: Graph Title Not Showing Up

How are you exporting?

 

If you specify the gpath you'll find your file and it should be exactly what you see on screen. 

Contributor
Posts: 39

Re: Graph Title Not Showing Up

I have SAS Enterprise Guide, but I do all of my work writing the code.  If I try to use EG to export, via an html file, or try to 'send to' an MS document like word/excel/powerpoint, SAS will export the title and graph, but not as 'one' image; the text will often export as a separate text box unassociated with the graph.

 

if i try to use code to export it, and as the user above suggested using 'gtitle', it still only exports the graph (no title) to the destination output.  doesn't matter if it's ODS html, or another kind of output i try.

SAS Super FREQ
Posts: 683

Re: Graph Title Not Showing Up

Hi

 

When using SAS Enterprise Guide, there is a setting to include titles and footnotes within the image.

 

Capture.PNG

 

When using your own code for the ODS destinations. Please ensure, that EG will not create any automatic output.

 

Bruno

Ask a Question
Discussion stats
  • 9 replies
  • 443 views
  • 0 likes
  • 3 in conversation