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-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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
  • 4 replies
  • 4484 views
  • 0 likes
  • 3 in conversation