Hello experts,
I would like to save the output of a PROC SGPLOT/SGPANEL with a BY statement on multiple pdf pages.
At present there are about 8 different categories - values of the by variable - that I would like to represent with a graph, hence using the BY statement is the easiest thing.
Problem is, the pdf output stops after the first graph, namely the first value of the by variable.
I browsed a bit on communities.sas.com and saw several papers/answers about multiple graphs in a PDF page (meaning one PDF page) but my case is the opposite.
As PDF output, I would like to obtain multiple PDF pages, generated by proc sgplot/proc sgpanel with a BY statement.
How to save all the graphs in PDF?
Kind regards
Have you sorted the input data set by the BY variable? When you use the BY statement in a SAS procedure, it needs to be sorted by that variable.
Are you using ODS LAYOUT in your code?
Do you have the ADVANCE=BYGROUP option on your ODS LAYOUT GRIDDED statement?
Hello,
I tried to use "ods layout gridded advance=bygroup;" but it prints only the first page, both as SAS Results and PDF.
Here is my SAS code: with this code it's possible to get the whole output in SAS results, but only the first page as PDF.
the variable KIND contains 8 unique values, hence the graph is grouped by KIND variable.
ODS layout start;
proc sgpanel data=work.ds_sas dattrmap=attrmap;
panelby kind/ novarname spacing=5 columns=1 ;
vbar YEAR / response=Percent group=category groupdisplay=stack attrid=myid;
rowaxis grid values=(0 to 100 by 10) label="Percentage";
colaxistable nhouse / class=category stat=sum title="house num.";
label category="Category"
kind="Kind";
run;
ods layout end;
Okay, instead of using ODS LAYOUT and ADVANCE=BYGROUP, remove the layout code and use STARTPAGE=BYGROUP on the ODS PDF statement. That should get you what you want.
Hope this helps!
Dan
@sassy7 wrote:
Yes, it's used, but as a PDF only the first page (pdf) is visible
Another example of where you really need to provide the entire code as interactions between all the options between procedure and ods destination options need to be known to address such.
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.