Hi,
I am using the BY statement with SGPLOT and I want my plots to appear in a pdf file with 3 graphs in each line, which I managed with the ODS statement below. However, when I do this, I no longer get the BY variable as a title above each graphs. Strangely, some of the graphs actually has the variable starting with ID=6 and all subsequent +4 (10, 14, 18, etc). I am using SAS Enterprise Guide 7.1.
ods pdf file='C:\test.pdf' startpage=no columns=3;
proc sgplot data=reshape noautolegend;
by ID;
scatter x=treat y=m / yerrorlower=lower
yerrorupper=upper
markerattrs=(color=black symbol=CircleFilled)
errorbarattrs=(color=black);
title1 'Log2 means with std. error bars';
xaxis label='uM HOCl (x10^2)';
yaxis label='Normalised Abundance (log2)';
run;
I am open to any suggestions to circumvent this issue. Thanks in advance.
Tina
Could you try
options nobyline;
ods pdf file='C:\test.pdf' startpage=no columns=3;
title "ID= #byval1 ";
proc sgplot data=reshape noautolegend;
by ID;
.............
Hi Ksharp,
Thank you for your suggestion.
Unfortunately, this did not solve my issue. The title-statement works when put in the SGPLOT-procedure rather than above as suggested, however, it only causes the BY-value to appear on the top of each page and not on each individual graph.
Best,
Tina
Hi:
By default, the titles should be "inside" the boundary of the graph. If you have turned that off by accident, you can always use the GTITLE option on the ODS PDF statement to get that turned back on. For example, see the example below. It is a simple scatter plot using SASHELP.CLASS, but does show the BY information and the title on every graph.
cynthia
Hi Cynthia,
Thank you for your response, it was very helpful. It seems the GTITLE option does not quite do the trick in SAS v.7.1, but I will check with our IT-department if we have the SAS v.9 at our faculty.
For now, I have simply removed the STARTPAGE=NO, since the COLUMNS statement allows me to have multiple graphs on one page without losing the BY line.
Tina
Hi Cynthia,
Yes, it is Enterprise Guide 7.1. Hmm, strangely, it does not work for me the way it should. Here is the code I used:
ods graphics / reset=all width=200px height=300px imagefmt=gif;
options orientation=landscape date nonumber;
ods pdf file='\\C:\test.pdf' columns=5 gtitle;
proc sgplot data=reshape noautolegend;
by ID;
scatter x=treat y=m / yerrorlower=lower
yerrorupper=upper
markerattrs=(color=black symbol=CircleFilled)
errorbarattrs=(color=black);
title1 'Log2 means with std. error bars';
xaxis label='uM HOCl (x10^2)';
yaxis label='Normalised Abundance (log2)';
run;
ods pdf close;
And my pdf output looks like this. So the BY line does not appear inside the graph as it did in your example. I also tried to put the GTITLE in a statement by itself, so I had ODS PDF GTITLE; which did give the exact same result. And I tried turning ODS GRAPHICS on, but that also didn't change anything.
Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!
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.
Ready to level-up your skills? Choose your own adventure.