BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
PaigeMiller
Diamond | Level 26

Let's say I create two plots and send them to ODS DOCUMENT. Then I want the output to appear as two side by side plots, I am trying to accomplish this via ODS LAYOUT GRIDDED and PROC DOCUMENT. But the two plots never show up side by side, they always show us one plot above the other plots. I have tried to do this with the output of PROC DOCUMENT going to HTML, doesn't work; I have tried to do this with the output of PROC DOCUMENT going to PDF, doesn't work.

 

How do I get this to show up as two plots side by side? Here is the PDF code. The HTML code is an obvious modification of the code below.

 

ods graphics/height=3in width=4in;
ods document name=work.test(write);
proc sgplot data=sashelp.class;
scatter x=height y=weight;
run;
proc sgplot data=sashelp.class;
scatter x=age y=weight;
run;
ods document close;

proc document name=work.test;
list/levels=all;
run;
quit;

ods pdf file="d:\myfolder\temp\plots.pdf" ;
ods layout gridded columns=2 rows=1 advance=proc;
proc document name=work.test(read);
    replay \sgplot#1\sgplot#1 / dest=pdf;
run;
proc document name=work.test(read);
    replay \sgplot#2\sgplot#1 / dest=pdf;
run;
ods layout end;
ods pdf close;

 

 

Thanks!

--
Paige Miller
1 ACCEPTED SOLUTION

Accepted Solutions
ChrisHemedinger
Community Manager

Try adding ODS REGION statements between each region you want in the layout.

 

ods layout gridded columns=2 rows=1 advance=proc;
ods region;
proc document name=work.test(read);
    replay \sgplot#1\sgplot#1 / dest=pdf;
run;
ods region;
proc document name=work.test(read);
    replay \sgplot#2\sgplot#1 / dest=pdf;
run;
ods layout end;
It's time to register for SAS Innovate! Join your SAS user peers in Las Vegas on April 16-19 2024.

View solution in original post

5 REPLIES 5
ChrisHemedinger
Community Manager

Try adding ODS REGION statements between each region you want in the layout.

 

ods layout gridded columns=2 rows=1 advance=proc;
ods region;
proc document name=work.test(read);
    replay \sgplot#1\sgplot#1 / dest=pdf;
run;
ods region;
proc document name=work.test(read);
    replay \sgplot#2\sgplot#1 / dest=pdf;
run;
ods layout end;
It's time to register for SAS Innovate! Join your SAS user peers in Las Vegas on April 16-19 2024.
DanH_sas
SAS Super FREQ

@ChrisHemedinger is correct. You can also drop the ADVANCE=PROC option in your example. I'm not sure why that option is not working for PROC DOCUMENT, but using ODS REGION statements should always create a clear cell delineations.

PaigeMiller
Diamond | Level 26

Well, that was simple. Thank you!

--
Paige Miller
Ksharp
Super User
/*Here is a alternative way.*/
%let path= c:\temp ;

options nodate nonumber;
ods listing gpath="&path."  style=htmlblue image_dpi=300;
ods graphics /width=3in height=3in reset=index  noborder  imagename='FAS' outputfmt=png ;
proc sgplot data=sashelp.class noautolegend ;
reg x=height y=weight/cli clm;
run;

ods graphics /width=3in height=3in reset=index  noborder  imagename='PPS' outputfmt=png;
proc sgplot data=sashelp.class;
scatter x=age y=weight;
run;


ods pdf file="&path.\want.pdf" style=minimal dpi=300  ;
data x;
x=' ';
y=' ';
run;
title;
proc report data=x  nowd noheader style={outputwidth=100% };
column x y;
define x/ style={ preimage="&path\FAS1.png"  bordertopcolor=white borderbottomcolor=white borderrightcolor=white borderleftcolor=white};
define y/ style={ preimage="&path\PPS1.png"  bordertopcolor=white borderbottomcolor=white borderrightcolor=white borderleftcolor=white};
run;

ods pdf close;

Ksharp_0-1689335253493.png

 

Ksharp
Super User
%let path= c:\temp ;

options nodate nonumber;
ods listing gpath="&path."  style=htmlblue image_dpi=300;
ods graphics /width=3in height=3in reset=index  noborder  imagename='FAS' outputfmt=png ;
proc sgplot data=sashelp.class noautolegend ;
reg x=height y=weight/cli clm;
run;

ods graphics /width=3in height=3in reset=index  noborder  imagename='PPS' outputfmt=png;
proc sgplot data=sashelp.class;
scatter x=age y=weight;
run;

ods graphics /width=3in height=3in reset=index  noborder  imagename='SS' outputfmt=png ;
proc sgplot data=sashelp.class noautolegend ;
ellipse x=height y=weight/group=sex;
scatter x=height y=weight/group=sex;
run;

ods graphics /width=3in height=3in reset=index  noborder  imagename='S' outputfmt=png;
proc sgplot data=sashelp.class;
scatter x=age y=weight/group=sex datalabel=name;
run;


ods pdf file="&path.\want.pdf" style=minimal dpi=300  ;
data x;
x=' ';y=' ';output;
x=' ';y=' ';output;
run;
title;
proc report data=x  nowd noheader style={outputwidth=100% };
column x y;
define x/display;
define y/display;
compute y;
n+1;
if n=1 then do;
call define('x','style','style={ preimage="&path\FAS1.png"  bordertopcolor=white borderbottomcolor=white borderrightcolor=white borderleftcolor=white}');
call define('y','style','style={ preimage="&path\PPS1.png"  bordertopcolor=white borderbottomcolor=white borderrightcolor=white borderleftcolor=white}');
end;
if n=2 then do;
call define('x','style','style={ preimage="&path\SS1.png"  bordertopcolor=white borderbottomcolor=white borderrightcolor=white borderleftcolor=white}');
call define('y','style','style={ preimage="&path\S1.png"  bordertopcolor=white borderbottomcolor=white borderrightcolor=white borderleftcolor=white}');
end;
endcomp;
run;

ods pdf close;

Ksharp_0-1689335456503.png

 

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 5 replies
  • 673 views
  • 3 likes
  • 4 in conversation