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:
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:
Is there any way to achieve what I want to do?
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;
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;
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: