Hi all,
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).
Thanks
Megan
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.
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:
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.
NEVER |
specifies not to insert page breaks, even before graphics procedures.
|
NO |
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.
|
I did post the code. What's there is my testing code. And no, i don't have a version without the macros written.
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?
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
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');
I wasn't sure where to put it, but seeing the &i, i put it inside the macro, but SAS didn't like that.
You forgot the ODS (or I did in my test code).
Either way, add the ODS to the ELSE statement and try that.
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??
options() is not for PDF
ods pdf startpage='now';
ods pdf startpage='never';
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.
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.
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.
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.