I want to put 3 graph in one page. I am using PROC SGPLOT procedure. below is my code. I have tried PROC GREPLAY but its not working.
ods listing gpath="XXX" dpi=300;
ods graphics / reset imagename="XXX" imagefmt=png height=4in width=7in noborder;
%inc titles;
Proc Sgplot data=abc nowall noborder;
where trtpn eq 1;
Vbarparm category=subjid response=pchg /GROUP=pchgcat1 name='TRT1';
Refline 20 -30 / lineattrs=(pattern=shortdash) ;
Xaxis label= "VVV";
Yaxis values=(100 to -100 by -20) label= "SSS";
Keylegend / title='' location=inside position=topright across=1 noborder;
footnote1 FONT='Times New Roman' j=left "DFDFF";
Run;
Switch to GTL, you can get the GTL code from what you have by putting:
Proc Sgplot data=abc nowall noborder tmplout="c:/text.txt";
In the file c:/text.txt you will find the gtl code which is generated. Then you add a layout gridded step to that, and add in your other graphs:
https://blogs.sas.com/content/?s=gridded
You may also be able to do it with sgpanel:
This is the best reference for GTL and sgplot:
I am using ODS listing and I am creating graph file PNG image. layout gridded wont work with ODS listing.
I am creating PNG file.
Hi:
You did NOT show all your code. What is your destination of interest? RTF, PDF, HTML. Wanting all 3 graphs on one "page" implies RTF or PDF.
Nobody can run your code, since you did not provide all the code or any data. Showing your program is good, but without data, in order for anyone to help you, they have to 1) guess what your data looks like and how it is structured and 2) spend time making fake data to test with and 3) guess what destination you're using.
I see that you've got ODS LISTING as an ODS statement, but with LISTING output, you are not creating GRAPHS for PDF or RTF, you will only create PNG files or image files that are single images, not a page with images on it.
With ODS PDF, on the other hand, if you size the images correctly, you can simply use STARTPAGE=NEVER to get them all on one page.
Or, you can do more advanced examples like this, using ODS LAYOUT and ODS REGION:
From this paper: http://support.sas.com/resources/papers/proceedings16/SAS5762-2016.pdf on page 24.
Hope this help,
Cynthia
Hi,
Thank you for your reply.
Below is dummy data.
SubjID | CHG | GRP |
101 | 80 | 1 |
102 | 70 | 1 |
103 | 60 | 1 |
104 | 50 | 2 |
105 | 40 | 2 |
106 | -10 | 2 |
107 | -20 | 3 |
108 | -30 | 3 |
109 | -70 | 3 |
I want to create kind of 3 graph in one page in PNG format. I have tried many procedure but didn't get. I have attached one file for Graph. Please check.
@SanjayAhir wrote:
I want to put 3 graph in one page. I am using PROC SGPLOT procedure. below is my code. I have tried PROC GREPLAY but its not working.
ods listing gpath="XXX" dpi=300;
ods graphics / reset imagename="XXX" imagefmt=png height=4in width=7in noborder;
%inc titles;
Proc Sgplot data=abc nowall noborder;
where trtpn eq 1;
Vbarparm category=subjid response=pchg /GROUP=pchgcat1 name='TRT1';
Refline 20 -30 / lineattrs=(pattern=shortdash) ;
Xaxis label= "VVV";
Yaxis values=(100 to -100 by -20) label= "SSS";
Keylegend / title='' location=inside position=topright across=1 noborder;
footnote1 FONT='Times New Roman' j=left "DFDFF";
Run;
Proc Greplay only works with the device based graphics that create catalog entries from Proc Gplot, Gchart and related.
What size "page" are you sending the output to? If you graph is created with a height of 4in then if your "page" is not larger than 12in tall then you cannot fit three graphs. You also need to make some allowance for space between graphs.
Typically to send multiple Sgplot graphs to a single document they would appear between an ODS destination open and close such as
Ods rtf <options>
proc sqplot;
proc sgplot;
proc sgplot;
ods rtf close;
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.