BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
mrafael03
Obsidian | Level 7

Hello,

I need to know on how I will separate the tables into 2 separate tabs. The codes below only resulted into 1 tab


/*1st TAB w/ 2 tables */
ods excel options (sheet_interval="none" sheet_name='TAB1');
PROC PRINT DATA=TABLE1 NOOBS;
RUN;

PROC PRINT DATA=TABLE2 NOOBS;
RUN;

 

 

/*2nd TAB */
ods excel options (sheet_name='TAB2');
PROC PRINT DATA=R.PRGNT_LIST NOOBS;
RUN;

 

1 ACCEPTED SOLUTION

Accepted Solutions
andreas_lds
Jade | Level 19

The value "now" for sheet_interval has  been added with 9.4m5 - try changing "now" to "proc", if that doesn't help, you should consider upgrading the sas version to a more recent release.

View solution in original post

13 REPLIES 13
SASKiwi
PROC Star
ods excel file = "MyExcel.xlsx";
ods excel options (sheet_interval="none" sheet_name='TAB1');
PROC PRINT DATA=TABLE1 NOOBS;
RUN;

PROC PRINT DATA=TABLE2 NOOBS;
RUN;

/*2nd TAB */
ods excel options (sheet_interval="none" sheet_name='TAB2');
PROC PRINT DATA=R.PRGNT_LIST NOOBS;
RUN;
ods excel close;
ketpt42
Quartz | Level 8
That doesn't work for me. I get everything on one sheet if I do that. If I set the 2nd sheet_interval option to 'now', the 2nd sheet is created as expected.
Tom
Super User Tom
Super User

Tell you want to start a new sheet.

ods excel filename='C:\downloads\msheets.xlsx';
ods excel options (sheet_interval="none" sheet_name='TAB1');
PROC PRINT DATA=sashelp.class (obs=4) NOOBS;
RUN;
PROC PRINT DATA=sashelp.class (firstobs=5 obs=10) NOOBS;
RUN;
ods excel options (sheet_interval='now' sheet_name='TAB2');
PROC PRINT DATA=sashelp.class(firstobs=11 obs=16) NOOBS;
RUN;
ods excel options (sheet_interval='none' );
PROC PRINT DATA=sashelp.class(firstobs=17) NOOBS;
RUN;
ods excel close;

 
mrafael03
Obsidian | Level 7
what's the use of firstobs and obs?
SASKiwi
PROC Star

FIRSTOBS specifies the row to start reading from and OBS specifies the row to stop reading from.

mrafael03
Obsidian | Level 7
The code isn’t working. Got an error on sheet_interval
SASKiwi
PROC Star

@mrafael03 -  Please post your SAS log.

mrafael03
Obsidian | Level 7

I got an error from when I added sheets 3 and 4 codes

ERROR: Argument now for word option sheet_interval not recognized. Expecting one of these keywords output, table, page, bygroup,

bygroups, proc, none or none.

 

SHEET 1

ods excel file=""

options (sheet_interval="none"

sheet_name="TAB1");

PROC PRINT DATA=R.TBL1 NOOBS;

RUN;

PROC PRINT DATA=R.TBL2 NOOBS;

RUN;

PROC PRINT DATA=R.TBL3  NOOBS;

RUN;

----------------

SHEET 2

ods excel options(sheet_interval='now'

sheet_name="TAB2");

PROC PRINT DATA=R.TBL4 NOOBS;

RUN;

----------------

SHEET 3

ods excel options(sheet_interval="none"

sheet_name="TAB3");

PROC PRINT DATA=R.TBL5 NOOBS;

RUN;

----------------

SHEET 4

ods excel options(sheet_interval='now'

sheet_name="TAB3");

PROC PRINT DATA=R.TBL5 NOOBS;

RUN;

andreas_lds
Jade | Level 19

@mrafael03 wrote:
The code isn’t working. Got an error on sheet_interval

Interesting, code works as expected using SAS 9.4m5. So, when you post the log as text, using the "insert code" button, please add information about the SAS version you are using.

mrafael03
Obsidian | Level 7
I'm using SAS 9.4m4
andreas_lds
Jade | Level 19

The value "now" for sheet_interval has  been added with 9.4m5 - try changing "now" to "proc", if that doesn't help, you should consider upgrading the sas version to a more recent release.

Tom
Super User Tom
Super User

@mrafael03 wrote:
what's the use of firstobs and obs?

So each PROC PRINT is printing different observations from SASHELP.CLASS to make it easier to check that the Excel file has the expected information.

 

They are called dataset options. Well the documentation calls them "data set" options but that is just because SAS documentation writers don't know how to spell dataset.

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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
  • 13 replies
  • 1965 views
  • 5 likes
  • 6 in conversation