BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Dave25
Quartz | Level 8

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;

1 ACCEPTED SOLUTION

Accepted Solutions
Dave25
Quartz | Level 8

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

4 REPLIES 4
Reeza
Super User

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;
PGStats
Opal | Level 21

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
Dave25
Quartz | Level 8

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

Dave25
Quartz | Level 8

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.

 

 

 

 

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

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