Data visualization with SAS programming

Border around SAS graphic SAS 9.2 pdf destination

Reply
Contributor
Posts: 56

Border around SAS graphic SAS 9.2 pdf destination

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;

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

Contributor
Posts: 51

Re: Border around SAS graphic SAS 9.2 pdf destination

Have you tried using Goptions?

Goptions Border;
Contributor
Posts: 56

Re: Border around SAS graphic SAS 9.2 pdf destination

yes . You can see in the sample code 

Super User
Super User
Posts: 7,711

Re: Border around SAS graphic SAS 9.2 pdf destination

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;

Contributor
Posts: 56

Re: Border around SAS graphic SAS 9.2 pdf destination

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.

Super User
Super User
Posts: 7,711

Re: Border around SAS graphic SAS 9.2 pdf destination

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.

Contributor
Posts: 56

Re: Border around SAS graphic SAS 9.2 pdf destination

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.

Super User
Super User
Posts: 7,711

Re: Border around SAS graphic SAS 9.2 pdf destination

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.

SAS Super FREQ
Posts: 1,139

Re: Border around SAS graphic SAS 9.2 pdf destination

[ Edited ]

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;

 

SAS Employee
Posts: 980

Re: Border around SAS graphic SAS 9.2 pdf destination

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

 

 

 

Ask a Question
Discussion stats
  • 9 replies
  • 454 views
  • 1 like
  • 5 in conversation