BookmarkSubscribeRSS Feed
ucvikas
Obsidian | Level 7

Dear experts,

 

I have some graphs created by gchart , gplot procedure . I want to have border around graph . I thought goptions border will de the work but I guess I miss something as it does not work for PDF destination . I see border in SAS report tab in SAS EG but when I open pdf file . it does not have graph.

 

Any idea how to get borders ? 

 

I use SAS 9.2 + linux OS . see example code 

 

********************************************************;

ods pdf file= "/tmp/test.pdf";

goptions reset=all border ;
title "US Electric Power - Revenue and Generation Sources";

proc gchart data=sashelp.electric (where=(year >= 2000)) ;
vbar year / discrete sumvar=Revenue subgroup=Customer;
run;
quit;
ods pdf close;

******************************************************;

9 REPLIES 9
RB1Kenobi
Quartz | Level 8
Have you tried using Goptions?

Goptions Border;
ucvikas
Obsidian | Level 7

yes . You can see in the sample code 

RW9
Diamond | Level 26 RW9
Diamond | Level 26

Eeek, why are you using gchart to make graphs, move to sgplot/GTL.

Your code seems incorrect, try:

ods graphics / reset=all height=15cm width=22cm border;

ucvikas
Obsidian | Level 7

Can you please explain what was incorrect in code ? I took it as sample from SAS website.

 

I tried your suggestion to use ods graphics . It did not work ( no border in pdf file) .

 

If moving to sgplot or/GTL will solve the problem then I can try but creating all the graphs again using diffrent procedure will take sometime.

RW9
Diamond | Level 26 RW9
Diamond | Level 26

Afraid I don't know then.  I only use GTL based procedures and that ods statement turns the border on and off no problems.  Sgplot and GTL is the most up to date version of the graphing system , for many years now.  Its is far more flexible and easy to use, hence why I suggest it.  Anyways, maybe someone else can help you with it as is.

ucvikas
Obsidian | Level 7

Useful advice . I'll keep that in mind for future graph coding. Can you give some link or document to know GTL ? I have never used it so far and it appears to be a powerful tool for graphs.

RW9
Diamond | Level 26 RW9
Diamond | Level 26

Sure, the best resource I have found is Sanjay's blog here:

http://blogs.sas.com/content/graphicallyspeaking/

 

It contains examples of every graph you can imagine, with proc template code or sgplot.  Very in depth and insightfull.  There are many pages, so scrolling through is good to see, and you can search for keywords.

Jay54
Meteorite | Level 14

Thanks, RW9 for your endorsement of GraphicallySpeaking.  Smiley Happy

 

The newest article in the blog above is meant for users like you who are new to the ODS Graphics procedures.  I recommend starting with SGPLOT procedure, and move to GTL later as you need.  Note:  One procedure - SGPLOT does everything, plots, bar charts, and more.  Here is the comparable code:

 

ods pdf file= "c:\test.pdf";
ods html close;
title "US Electric Power - Revenue and Generation Sources";
proc sgplot data=sashelp.electric (where=(year >= 2000)) ;
  vbar year / response=Revenue group=Customer;
run;
ods pdf close;

 

GraphGuy
Meteorite | Level 14

Since the goptions border isn't working in this situation, you could "draw" a border using annotate, as a work-around.

 

Here's a simple example showing how to do that - you should be able to re-use this anno_border dataset easily with your gchart. Feel free to modify the color and size (width) of the line - I'm using red just so it's more obvious which line it is.

 

data anno_border;
xsys='3'; ysys='3'; hsys='3'; when='a';
function='move'; x=0; y=0; output;
function='box'; x=100; y=100; line=0; style='empty'; color='red'; size=1.0; output;
run;

 

proc gchart data=sashelp.class anno=anno_border;
hbar name / type=sum sumvar=height descending;
run;

 

gchart.png

 

 

 

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
  • 9 replies
  • 2134 views
  • 1 like
  • 5 in conversation