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;
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.
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;
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;
Thanks for the suggestion - I neglected to add that I'm using xaxistable in my acual graphs, so sgpanel doesn't work.
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.
Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.
Register today!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.
Select SAS Training centers are offering in-person courses. View upcoming courses for: