SAS Programming

DATA Step, Macro, Functions and more
BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
Ronein
Meteorite | Level 14

Hello

I wan to export 2 table into sheet1 and 2 tables into sheet 2

What is the way please?

 

/****I would like to have several tables on Sheet 1 and several more on Sheet 2***/
/****I would like to have several tables on Sheet 1 and several more on Sheet 2***/
/****I would like to have several tables on Sheet 1 and several more on Sheet 2***/
ods excel file="/usr/local/SAS/SASUsers/LabRet/UserDir/udclk79/ABC12.xlsx"
options(sheet_name="Sh1" sheet_interval="none");
title 'Table1';
proc print data=sashelp.class(obs=3) noobs;
run;
title 'Table2';
proc print data=sashelp.shoes(obs=3) noobs;
run;

ods excel options(sheet_name="Sh2" sheet_interval="none");
proc print data=sashelp.cars(obs=5);
run;
title 'Table2';
proc print data=sashelp.shoes(obs=3) noobs;
run;
ods excel close;
1 ACCEPTED SOLUTION

Accepted Solutions
svh
Lapis Lazuli | Level 10 svh
Lapis Lazuli | Level 10

LinusH's post had the answer--the second 'ODS excel options' statement needs sheet_interval set to "now". 

 

ods excel file="ABC12.xlsx"
options(sheet_name="Sh1" sheet_interval="none");
title 'Table1';
proc print data=sashelp.class(obs=3) noobs;
run;
title 'Table2';
proc print data=sashelp.shoes(obs=3) noobs;
run;

ods excel options(sheet_name="Sh2" sheet_interval="now"); /*This tells SAS to start a new sheet for next PROCs*/
proc print data=sashelp.cars(obs=5);
run;
title 'Table2';
proc print data=sashelp.shoes(obs=3) noobs;
run;
ods excel close;

View solution in original post

4 REPLIES 4
Ronein
Meteorite | Level 14
I tried none and after none or none and after porc but nothing provide desire results
svh
Lapis Lazuli | Level 10 svh
Lapis Lazuli | Level 10

LinusH's post had the answer--the second 'ODS excel options' statement needs sheet_interval set to "now". 

 

ods excel file="ABC12.xlsx"
options(sheet_name="Sh1" sheet_interval="none");
title 'Table1';
proc print data=sashelp.class(obs=3) noobs;
run;
title 'Table2';
proc print data=sashelp.shoes(obs=3) noobs;
run;

ods excel options(sheet_name="Sh2" sheet_interval="now"); /*This tells SAS to start a new sheet for next PROCs*/
proc print data=sashelp.cars(obs=5);
run;
title 'Table2';
proc print data=sashelp.shoes(obs=3) noobs;
run;
ods excel close;
Tom
Super User Tom
Super User

The value you pass with SHEET_NAME= is ignored when you tell ODS EXCEL not to make a new sheet by using SHEET_INTERVAL='NONE'.

 

Use SHEET_INTERVAL='NOW' instead.

ods excel options(sheet_name="Sh2" sheet_interval="now");

sas-innovate-white.png

Our biggest data and AI event of the year.

Don’t miss the livestream kicking off May 7. It’s free. It’s easy. And it’s the best seat in the house.

Join us virtually with our complimentary SAS Innovate Digital Pass. Watch live or on-demand in multiple languages, with translations available to help you get the most out of every session.

 

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
  • 4 replies
  • 470 views
  • 5 likes
  • 4 in conversation