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:
And here is what I want with the title "Total Loaded Mileage" at the top.
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?
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
i tried this and it didn't work :(. the html output had no title.
Post your full code and log please.
Specify gpath on the html statement as well.
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;
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.
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:
This second image is what I want, where the title is IN the larger border box for the graph (in the circled red space):
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
how does one get the title "Increase of Height with Age" INSIDE the box??
How are you exporting?
If you specify the gpath you'll find your file and it should be exactly what you see on screen.
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.
Hi
When using SAS Enterprise Guide, there is a setting to include titles and footnotes within the image.
When using your own code for the ODS destinations. Please ensure, that EG will not create any automatic output.
Bruno
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.
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.