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;	

sas-innovate-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!

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
  • 1724 views
  • 0 likes
  • 1 in conversation