Hi All,
I would like to ask for your help on the below.
I would like to send multiple outputs on the same sheet next to each other using the ODS destination for excel.
I know how to do it vertically using
sheet_interval="NONE"
but I have not been able to figure how to put the outputs next to each other.
Below a piece of code that displays the outputs vertically:
data productA;
input CODE $ Value;
datalines;
A 10
B 20
C 30
;
run;
data productB;
input CODE $ Value;
datalines;
D 110
E 220
F 330
;
run;
ODS EXCEL
FILE = "&work_path/reports"
OPTIONS(sheet_name="PRODUCTS"
sheet_interval="NONE");
PROC REPORT DATA=productA;
RUN;
PROC REPORT DATA=productB;
RUN;
ODS EXCEL CLOSE;
The above piece of code returns:
Is there any way to put the outputs next to each other instead please?
Thanks
ODS Excel does not offer that capability.
You could join (merge) the data sets in SAS before writing to Excel, but then you would need different column names after the join (merge), such as CODE, VALUE, CODE1, VALUE1. Then when you write to Excel, there is no blank column between the two tables (unless you also include a blank column in your SAS code when you do the join)
https://support.sas.com/rnd/base/ods/odsmarkup/msoffice2k/index.html
After you got this XML file, you could convert it into a native Excel file by this macro.
43496 - Convert files created using an ODS destination to native Microsoft Excel files (sas.com)
Here is an example:
options noxsync noxwait;
%include "c:\temp\a\msoffice2k_x.sas";
ods noresults;
ods _all_ close;
ods tagsets.msoffice2k_x file="c:\temp\a\panels.xls"
options(panelcols="3") style=normal;
proc print data=sashelp.prdsale(obs=10);
var actual predict country region;
where country="CANADA";
title "Canada Sales";
run;
proc print data=sashelp.prdsale(obs=10);
var actual predict country region;
where country="U.S.A.";
title "USA Sales";
run;
proc print data=sashelp.prdsale(obs=10);
var actual predict country region;
where country="GERMANY";
title "Germany Sales";
run;
ods tagsets.msoffice2k_x options(panelcols="2") ;
proc print data=sashelp.prdsale(obs=20);
where region="EAST";
title "East Sales";
run;
proc print data=sashelp.prdsale(obs=20);
where region="WEST";
title "West Sales";
run;
ods tagsets.msoffice2k_x close;
%include "c:\temp\a\convert.sas";
%convert_files(default=c:\temp\a ,ext=xls);
Maybe Report Writing Interface could be used to place tables next to each other. I never had to do this, so i can't provide any code.
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.