The SAS Output Delivery System and reporting techniques

sgplot, ods pdf, and titles

Accepted Solution Solved
Reply
Contributor
Posts: 27
Accepted Solution

sgplot, ods pdf, and titles

I'm trying to create a number of by-graphs, with a title on the top of the page, and the by-values inside the graphs (and a new page for each byvar1) - tried lots of combinations, but no luck - below is stripped-down code with what I'm trying to accomplish.

Any suggestions would be greatly appreciated,

Dave

 

data a;
input byvar1 $ byvar2 $ graphvar $ response;
cards;
A1 B1 A 2
A1 B2 A 2
A2 B1 A 2
A2 B2 A 2
;
run;
options orientation=portrait byline;
ods pdf file = 'C:\temp\test.pdf';
ods graphics / height=4in;
title1 'Title I want at the Top of the Page';
ods startpage = no;
proc sgplot data=a;
vbar graphvar/response=response;
by byvar1 byvar2 ;
run; quit;
ods pdf close;


Accepted Solutions
Solution
‎01-23-2016 09:03 AM
Contributor
Posts: 27

Re: sgplot, ods pdf, and titles

Finally e-mailed SAS Tech Support, and they suggested "When you get a chance specify NOGTITLE on the ODS PDF statement and let me know if that produces the results you want."

 

This got the  1st page is behave ok, but didn't  get what I need on page 2 (the by-info for the 1st graph on page 2 was on the bottom of page 1)

 

Then it finally came to me  – I just needed to  make the "ods graphics / Height =" larger, till the by-info title shifted to the 2nd page.

 

 

 

 

View solution in original post


All Replies
Super User
Posts: 19,869

Re: sgplot, ods pdf, and titles

https://support.sas.com/documentation/cdl/en/lestmtsref/68024/HTML/default/viewer.htm#p10gcmrmf83iax...

 

Look into the #byvarn within title to control the titles. Getting one at top of page and one embedded in Graph may be a bit harder. Consider using ODS TEXT= for the first and Title for the second and see how that works? I can't seem to get it repeating across pages.

 

options orientation=portrait nobyline;
ods pdf file = 'C:\temp\test.pdf';
ods graphics / height=4in;
ods text= 'Title I want at the Top of the Page';
title1 "My byvar titles byvar1 = #byvar1 and byvar2 = #byvar2";
ods startpage = no;
proc sgplot data=a;
vbar graphvar/response=response;
by byvar1 byvar2 ;
run; quit;
ods pdf close;
Respected Advisor
Posts: 4,934

Re: sgplot, ods pdf, and titles

If you want a single graph per page then do not use startpage=no. Also use system option nobyline and #BYVAR and #BYVAL in your titles

If you want multiple graphs per page with a by-group header then you should consider using SGPANEL :

 

options nonumber nodate orientation=portrait;
ods pdf file="&sasforum.\graphs\twoperpage.pdf";
ods graphics / height=9in width=6in border=off;
title;
proc sgpanel data=sashelp.heart;
panelby Weight_Status / columns=1 rows=2 spacing=20 novarname skipemptycells noborder;
vbar Smoking_Status / stat=freq;
run;
ods pdf close;
PG
Contributor
Posts: 27

Re: sgplot, ods pdf, and titles

Thanks for the suggestion - I neglected to add that I'm using xaxistable in my acual graphs, so sgpanel doesn't work.

Solution
‎01-23-2016 09:03 AM
Contributor
Posts: 27

Re: sgplot, ods pdf, and titles

Finally e-mailed SAS Tech Support, and they suggested "When you get a chance specify NOGTITLE on the ODS PDF statement and let me know if that produces the results you want."

 

This got the  1st page is behave ok, but didn't  get what I need on page 2 (the by-info for the 1st graph on page 2 was on the bottom of page 1)

 

Then it finally came to me  – I just needed to  make the "ods graphics / Height =" larger, till the by-info title shifted to the 2nd page.

 

 

 

 

☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 4 replies
  • 892 views
  • 0 likes
  • 3 in conversation