05-05-2017 10:09 AM - edited 05-05-2017 11:03 AM
I have SGPLOT code working and it outputs 40+ graphs (this is dependent on the input and can change from run to run) to a pdf. I'm trying to force 2 graphs on one page as a space saver. I've tried startpage=no or startpage=never, and any of those end up reducing everything to one page and i only end up with 1 page and 1 graph instead of 40 pages and 40 graphs.
Here's my code: (EDITED to note that i do not have the abilty to post the actual code as it's on an enclave computer, with no internet access and no copy rights out of it into another machine).
05-05-2017 10:18 AM
Look at adjusting your PAGESIZE option for output with the OPTIONS statement and using ODS Graphics options to set the height and width of your graph output.
ODS Graphics/ height =4in width=7in;
would set the graph size to 4 by 7 inches.
If your pagesize is at least 8.5in by 8in two should fit. There will be some space between the graphs.
When you say that you have created one page with one graph where you expect more then you seem to have something else going one.
Also you show a %do loop but no %end statement so you may be having issues with your macro in general that would be very hard to diagnose without data and full code.
05-05-2017 10:30 AM - edited 05-05-2017 10:37 AM
Sorry, there is an actual %end. I have an if/then based on something else and pulled the other one out to simplify the picture for the post. I've updated the picture.
When i do startpage=no or startpage=never, that's when it goes from 1 graph per page and 40+ pages to just 1 graph and 1 page. When remove startpage, then it goes back to normal.
I added the ods graphics height and width and it made the graphs smaller, and visually there is plenty of page left for a second graph per page, but there's still only one graph per page.
EDITED to add screenshot of graph output. As you can see, there's PLENTY of room for 2 on each page:
05-05-2017 10:51 AM
Please show the actual code with the ods options.
Did you have a working program without macros that would place two graphs as needed?
From online documentation for ODS PDF
STARTPAGE=NEVER | NO | NOW | YES
controls page breaks.
specifies not to insert page breaks, even before graphics procedures.
specifies that no new pages be inserted at the beginning of each procedure, or within certain procedures, even if new pages are requested by the procedure code. A new page will begin only when a page is filled or when you specify STARTPAGE=NOW.
05-05-2017 10:57 AM
FYI - Code as a picture and that we can't run isn't very helpful. Ideally you'd use a SASHELP dataset and we could replicate your issue. At minimum I'm not likely to type out your code to test it.
Given what you've shown, startpage should work, but I don't see that listed anywhere in the code.
Can you show the code when you have that option on? And what version of SAS are you using?
05-05-2017 11:00 AM
I can't post the actual code. SAS is on another computer that is separate from the internet and doesn't allow copy and paste out of it. So screenshots is the best i can do.
SAS 9.4 32bit
05-05-2017 11:04 AM
I'd probably do something like the following, but this is untested.
%if %sysfunc(mod(&i, 2)) = 0 %then %do; ods pdf options(startpage='now'); %end; %else ods pdf options(startpage='never');
05-05-2017 11:57 AM
Looks like i did. For some reason it recognizes the first one but not the second one. I don't see any different in the ods pdf line, do you??
05-05-2017 12:31 PM
Same thing. Recognizes the first line, not the second. Gotta love the error with 'never' because it's looking for never. ???
I removed the quotes around now and never just in case and then it had a problem with the proc sgplot line.
05-05-2017 01:06 PM
Try changing the %else to %else %do; ods PDF ... etc; %end;
If you can mock up a simple example on your desktop that we can run, using SASHELP.CARS or Heart then I can test it on my side. Unfortunately I don't have time to do this today.
05-05-2017 01:21 PM
Well it works with 4 graphs right in a row, so maybe it has something to do with the do loop in my real code? Because when i do startpage='never' on my code, it overwrites each one each time and i end up with only 1 page and 1 graph.