BookmarkSubscribeRSS Feed
sanjay1
Obsidian | Level 7

Hi Experts,

 

I am trying to export multiple datasets into two different sheets in same excel file. But I am getting an error that export unsuccesful.

Below is my code.

 


PROC EXPORT DATA= ab
OUTFILE=
"/&Main/desktop/file/ab.xlsx"
DBMS=XLSX REPLACE;
Sheet1='ab';
RUN;

 


PROC EXPORT DATA= ab1
OUTFILE=
"/&Main/desktop/file/ab1.xlsx."
DBMS=XLSX REPLACE;
Sheet1='ab1';
RUN;

 

Thanks,

Sanjay

6 REPLIES 6
PaigeMiller
Diamond | Level 26

Show us the LOG, including all of your code, and the actual error message.

 

Click on the {i} icon and paste the log into the window that appears. Do not paste the log into your message any other way.

--
Paige Miller
andreas_lds
Jade | Level 19

I can't see any error in the code you posted. Tried to export sashelp.cars and sashelp.class using proc export twice, no problem, both sheets are created as expected. Maybe an issue caused by the sas version you are using, will need to see the log,

sanjay1
Obsidian | Level 7

Here is the log

 

PROC EXPORT DATA= ab
471 OUTFILE=
472 "C:\Users\290014098\Desktop\SAS Codes\ab.xlsx"
473 DBMS=XLSX REPLACE;
474 Sheet1='ab';
------
1
WARNING 1-322: Assuming the symbol SHEET was misspelled as Sheet1.

475 RUN;

 

NOTE: The export data set has 1 observations and 2 variables.
NOTE: "C:\Users\290014098\Desktop\SAS Codes\ab.xlsx" file was successfully created.
NOTE: PROCEDURE EXPORT used (Total process time):
real time 0.11 seconds
cpu time 0.06 seconds


476
477
478
479
480 PROC EXPORT DATA= ab1
481 OUTFILE=
482 "C:\Users\290014098\Desktop\SAS Codes\ab.xlsx."
483 DBMS=XLSX REPLACE;
484 Sheet2='ab1';
------
1
WARNING 1-322: Assuming the symbol SHEET was misspelled as Sheet2.

485 RUN;

NOTE: The export data set has 1 observations and 2 variables.
NOTE: "C:\Users\290014098\Desktop\SAS Codes\ab.xlsx.xlsx" file was successfully created.
NOTE: PROCEDURE EXPORT used (Total process time):
real time 0.22 seconds
cpu time 0.07 seconds

PaigeMiller
Diamond | Level 26

Please help us out and comply with the earlier request.

 

Click on the {i} icon and paste the log into the window that appears. Do not paste the log into your message any other way. 

 

This preserves the formatting of the log and makes it easier to read.

 

Thanks.

--
Paige Miller
ballardw
Super User

@sanjay1 wrote:

Here is the log

 

PROC EXPORT DATA= ab
471 OUTFILE=
472 "C:\Users\290014098\Desktop\SAS Codes\ab.xlsx"
473 DBMS=XLSX REPLACE;
474 Sheet1='ab';
------
1
WARNING 1-322: Assuming the symbol SHEET was misspelled as Sheet1.

475 RUN;

 

NOTE: The export data set has 1 observations and 2 variables.
NOTE: "C:\Users\290014098\Desktop\SAS Codes\ab.xlsx" file was successfully created.
NOTE: PROCEDURE EXPORT used (Total process time):
real time 0.11 seconds
cpu time 0.06 seconds


476
477
478
479
480 PROC EXPORT DATA= ab1
481 OUTFILE=
482 "C:\Users\290014098\Desktop\SAS Codes\ab.xlsx."
483 DBMS=XLSX REPLACE;
484 Sheet2='ab1';
------
1
WARNING 1-322: Assuming the symbol SHEET was misspelled as Sheet2.

485 RUN;

NOTE: The export data set has 1 observations and 2 variables.
NOTE: "C:\Users\290014098\Desktop\SAS Codes\ab.xlsx.xlsx" file was successfully created.
NOTE: PROCEDURE EXPORT used (Total process time):
real time 0.22 seconds
cpu time 0.07 seconds


You may want to think about what REPLACE means.

In proc export that means it REPLACES the existing file. So you have told the code to get rid of the first file.

andreas_lds
Jade | Level 19

The option name is "sheet" not "sheet1".

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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
  • 6 replies
  • 884 views
  • 2 likes
  • 4 in conversation