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

Hi,

 

When using proc export, could it be that newfile=yes is not working with dbms=xlsx?

 

The following code add a second tab to an existing excel file

rather than deleting the first excel file and creating a new one with one two.

 

It works as expected with dbms=excel tho.

 

Best Regards,

 

 

filename demo "&xxdemo./reporting/class.xlsx";

proc export data    = sashelp.class
            dbms    = xlsx
            outfile = demo;
     sheet='All Students'n;
run;

filename demo;

filename demo "&xxdemo./reporting/class.xlsx";

proc export data    = sashelp.class (where=(sex='M'))
            dbms    = xlsx /*excle*/
            outfile = demo;
     newfile = y;
     sheet='Male'n;
run;

filename demo;
1 ACCEPTED SOLUTION
6 REPLIES 6
ghosh
Barite | Level 11
 1          OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
 70         
 71         filename demo "~/dat/class.xlsx";
 72         
 73         proc export data    = sashelp.class
 74                     dbms    = xlsx
 75                     outfile = demo;
 76              sheet='All Students'n;
 77         run;
 
 NOTE: The export data set has 19 observations and 5 variables.
 NOTE: "DEMO" file was successfully created.
 NOTE: PROCEDURE EXPORT used (Total process time):
       real time           0.01 seconds
       user cpu time       0.00 seconds
       system cpu time     0.00 seconds
       memory              2471.43k
       OS Memory           29532.00k
       Timestamp           05/17/2020 06:18:55 PM
       Step Count                        24  Switch Count  0
       Page Faults                       0
       Page Reclaims                     831
       Page Swaps                        0
       Voluntary Context Switches        9
       Involuntary Context Switches      0
       Block Input Operations            0
       Block Output Operations           16
       
 
 78         
 79         filename demo;
 NOTE: Fileref DEMO has been deassigned.
 80         
 81         filename demo "~/dat/class.xlsx";
 82         
 83         proc export data    = sashelp.class (where=(sex='M'))
 84                     dbms    = xlsx /*excle*/
 85                     outfile = demo;
 86              newfile = y;
 87              sheet='Male'n;
 88         run;
 
 NOTE: The export data set has 10 observations and 5 variables.
 NOTE: "DEMO" file was successfully created.
 NOTE: PROCEDURE EXPORT used (Total process time):
       real time           0.01 seconds
       user cpu time       0.00 seconds
       system cpu time     0.00 seconds
       memory              2814.96k
       OS Memory           30044.00k
       Timestamp           05/17/2020 06:18:55 PM
       Step Count                        25  Switch Count  0
       Page Faults                       0
       Page Reclaims                     552
       Page Swaps                        0
       Voluntary Context Switches        21
       Involuntary Context Switches      0
       Block Input Operations            16
       Block Output Operations           16
       
 
 89         
 90         filename demo;
 NOTE: Fileref DEMO has been deassigned.
 91         
 92         OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;

It works for me on SODA (SAS On Demand for Academics) .  I am able to open the Excel file and view the contents in Windows 10

xxformat_com
Barite | Level 11
I can see the content of the file. It is just the one I was expected. I was expecting the same one as with dbms=excel.
Kurt_Bremser
Super User

This is documented behavior. SAS will create a new spreadsheet; if the Excel file already exists, no new file is created, but a new sheet within the file. If the sheet already exists, and no REPLACE option is given, the sheet is not overwritten, and you will be notified.

xxformat_com
Barite | Level 11
I could not find the documentation where newfile=yes was not working with dbms=xlsx. Would you have the link?

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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
  • 6 replies
  • 1309 views
  • 0 likes
  • 3 in conversation