Turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

- Home
- /
- Programming
- /
- Programming
- /
- Multiple graphs per page with many graphs

Options

- RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page

🔒 This topic is **solved** and **locked**.
Need further help from the community? Please
sign in and ask a **new** question.

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

Posted 10-23-2019 10:00 PM
(767 views)

Hi all. I am trying to print 4 graphs per page to a PDF file. I have many graphs (200 for now) as I am drawing using PROC SGPLOT and BY statement. I searched online for the solution but all of them involve manually indicating the position of each graphs which is not ideal in my case. Is there a solution where I can tell SAS to print 4 graphs into 1 page instead of 1 big graph per page?

My code is:

```
proc sgplot data=prices;
by stock;
series x=date y=price;
series x=date y= volume/y2axis;
run;
```

1 ACCEPTED SOLUTION

Accepted Solutions

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

You may want to consider SGPANEL instead of SGPLOT and use the By variable Stock as a Panelby variable. You can specify the number of columns of (across graphs) and an appropriate number of rows of graphs would be made.

Try this and see if it gets close to what you want:

proc sgpanel data=prices; panelby stock /columns=2; series x=date y=price; series x=date y= volume/y2axis; run;

There are a number of options on laying out the appearance depending on data.

4 REPLIES 4

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

Have you looked at the ODS LAYOUT GRIDDED statement?

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

I did try it. but could not get it to work. I tried:

`ods pdf file = "graphs.pdf" startpage=never; `

ods layout gridded columns=2;
proc sgplot data=prices;
by stock;
series x=date y=price;
series x=date y= volume/y2axis;
run;
ods layout end;
ods pdf close;

I got 4 graphs per page which is nice but they are all in 1 columns. I would like to get 2x2 or 3x3 graphs. That is 3 columns and 3 rows.

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

You may want to consider SGPANEL instead of SGPLOT and use the By variable Stock as a Panelby variable. You can specify the number of columns of (across graphs) and an appropriate number of rows of graphs would be made.

Try this and see if it gets close to what you want:

proc sgpanel data=prices; panelby stock /columns=2; series x=date y=price; series x=date y= volume/y2axis; run;

There are a number of options on laying out the appearance depending on data.

**SAS Innovate 2025** is scheduled for May 6-9 in Orlando, FL. Sign up to be **first to learn** about the agenda and registration!

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.

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