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

I can't seem to get the display I need for the output of sgplot with a by-group option. The output should go to ODS PDF.

 

If I don't use options nobyline the text displayed above each plot is "#byvar1=#byval1" and I would like it to be only "#byval1". If I disable byline, and try to set the plot title to title "#byval1" then only the first plot gets the title printed above. Here is my code

/* prepare the data */
proc sort data=sashelp.class out=c;
   by sex;
run;

/* ODS options */
option papersize=(10in 5.63in) ;
option nodate nonumber;
ods escapechar = "^";

options  leftmargin = .1in
 rightmargin = .1in
 topmargin = .1in
 bottommargin = .05in ;

ODS _ALL_ CLOSE;
TITLE; 
FOOTNOTE ;

ODS PDF FILE="output.pdf"  
	style = Styles.Pearl NOBOOKMARKGEN nogtitle nogfootnote dpi = 300 ;

options byline;

ods graphics / width=4.5in height=1.9in;
ods layout gridded columns=2 rows=1 advance=bygroup;

proc sgplot data=c ;
   scatter y=weight x=height;
   by sex;
run;

ods layout end; 
ODS PDF CLOSE;

This produces the following output:

with_byline.png

 

If I change the following in the code:

options nobyline;

proc sgplot data=c ;
   scatter y=weight x=height;
   by sex;
   title "#byval1";
run;

I get this output:

without_byline.png

 

Is there any way to achieve what I want to do?

1 ACCEPTED SOLUTION

Accepted Solutions
MDaniel
Obsidian | Level 7

The fix is amazingly simple and I should have thought about this earlier - gtitle needs to be enabled when defining the ODS. Code would look like this:

 

ODS PDF FILE="output.pdf"  
	style = Styles.Pearl NOBOOKMARKGEN gtitle nogfootnote dpi = 300 ;
	
options nobyline;	
	
proc sgplot data=c ;
   scatter y=weight x=height;
   by sex;
   title "#byval1";
run;	

View solution in original post

1 REPLY 1
MDaniel
Obsidian | Level 7

The fix is amazingly simple and I should have thought about this earlier - gtitle needs to be enabled when defining the ODS. Code would look like this:

 

ODS PDF FILE="output.pdf"  
	style = Styles.Pearl NOBOOKMARKGEN gtitle nogfootnote dpi = 300 ;
	
options nobyline;	
	
proc sgplot data=c ;
   scatter y=weight x=height;
   by sex;
   title "#byval1";
run;	

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

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.

SAS Training: Just a Click Away

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

Browse our catalog!

Discussion stats
  • 1 reply
  • 1636 views
  • 0 likes
  • 1 in conversation