BookmarkSubscribeRSS Feed
Zatere
Quartz | Level 8

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:

Zatere_1-1706697259983.png

 

 

Is there any way to put the outputs next to each other instead please?

 

Thanks

3 REPLIES 3
PaigeMiller
Diamond | Level 26

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)

--
Paige Miller
Ksharp
Super User

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

Ksharp_2-1706772898677.png

Ksharp_0-1706773894961.png

 

andreas_lds
Jade | Level 19

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.

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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
  • 3 replies
  • 605 views
  • 2 likes
  • 4 in conversation