BookmarkSubscribeRSS Feed
SanjayAhir
Obsidian | Level 7

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;

8 REPLIES 8
RW9
Diamond | Level 26 RW9
Diamond | Level 26

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:

http://support.sas.com/documentation/cdl/en/grstatproc/62603/HTML/default/viewer.htm#sgpanel-stmt.ht...

 

This is the best reference for GTL and sgplot:

http://blogs.sas.com/content/graphicallyspeaking/

SanjayAhir
Obsidian | Level 7

I am using ODS listing and I am creating graph file PNG image. layout gridded wont work with ODS listing.

Reeza
Super User
What type of 'page' are you referring to? Usually that would mean ODS PDF or RTF to me, but your code only shows listing which is the text output and has no concept of 'pages'.
SanjayAhir
Obsidian | Level 7

I am creating PNG file.

Reeza
Super User
PNG files don't have 'page' concept, they're image files. You need to set the PNG dimensions to your 'page' dimensions. The only way I know of to get two graphs onto one PNG would be to create the GTL code and do it in one SGRENDER so hopefully someone has a better suggestion.
Cynthia_sas
SAS Super FREQ

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.

class_vbar_onepage.png

 

Or, you can do more advanced examples like this, using ODS LAYOUT and ODS REGION:

paper_example.png

 

From this paper: http://support.sas.com/resources/papers/proceedings16/SAS5762-2016.pdf on page 24.

Hope this help,
Cynthia

SanjayAhir
Obsidian | Level 7

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.

 

 

ballardw
Super User

@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;

 

 

SAS Innovate 2025: Register Now

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!

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.

SAS Training: Just a Click Away

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

Browse our catalog!

Discussion stats
  • 8 replies
  • 5652 views
  • 1 like
  • 5 in conversation