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

I am trying to convert xml files to xlsx files in SAS EG v7.15 that is hosted on an AWS server. 

The way the files are currently created is by using the following code below and a macro to name the files according to a list of agency names and numbers.

ods tagsets.excelxp
path = '/data//Test'
file="agency_report_&name._&agency..xml"

ods tagsets.excelxp close;
ods listing close;

 

I have seen previous post about users using the following code to convert all the files from xml to xlsx

options noxsync noxwait;
%convert_files(default=/data/Test,ext=xml);

 

However, when I do this I get the following three error statements 

ERROR 13-12: Unrecognized SAS option name NOXSYNC.

ERROR 13-12: Unrecognized SAS option name NOXWAIT.

ERROR: Shell escape is not valid in this SAS session.

 

The macro %convert_files is run before I call it. Does anyone know why this is not working or if there is another way for me to convert these xml files to xlsx? 

1 ACCEPTED SOLUTION

Accepted Solutions
jimbarbour
Meteorite | Level 14

Why not just go straight to Excel (xlsx)?  Don't use the essentially obsolete ExcelXP tag set.  Use the ODS Excel destination.  What version of SAS are you running?  Unless it's a fairly old version, you should be able to use the Excel destination.  If you use the Excel destination, then you don't need to convert XML to XLSX; you'll have XLSX directly.

 

This paper might be helpful:

https://blogs.sas.com/content/sgf/2017/02/20/tips-for-using-the-ods-excel-destination/

 

Jim

View solution in original post

5 REPLIES 5
ballardw
Super User

Why? The setting of your session have disabled the X command and related options most likely.

This is typically set by admins of a SAS server install such as EG to prevent headaches caused by uncontrolled submission of operating system commands.

 

If you have the right license options I would be tempted to try:

ods excel
path = '/data//Test'
file="agency_report_&name._&agency..xlsx"
/*  I really hope you have code that goes here*/
ods excel close;

If you must have the XML and the XLSX you can have multiple ODS output destinations open at one time. Just make sure to close them appropriately.

I typically used a "balanced sandwich" approach to consistently open and close multiple destinations like:

Ods tagsets.excelxp <tagset options>;

Ods rtf  < rtf options>;

<output generating code goes here>

ods rtf close;

ods tagsets.excelxp close; 

The order of the close bits shouldn't make a difference but I like to make sure first opened is last closed just to find the statements when needed.

Tom
Super User Tom
Super User

Are you asking how to convert an XML files generated by TAGSETS.EXCELXP to an XSLX file?
The best way is to open the XML file with Excel itself and then save it as an XLSX file.

You didn't provide any code for the macro you are calling but from the error messages you are getting I suspect it is trying to do that.  Since you are using Enterprise Guide to run your SAS code (instead of just running the SAS code directly using SAS itself)  make sure the computer where SAS is running actually has Excel installed.

Iske
Calcite | Level 5

No, I am asking after I have created this file as xml, how do automatically convert these files to xlsx. Since this process outputs about 250 files opening and saving as xlsx would be a lot of work for a monthly report. So I am trying to find a way to work around it. 

 

The virtual desktop that I use for work does have Excel installed. 

jimbarbour
Meteorite | Level 14

Why not just go straight to Excel (xlsx)?  Don't use the essentially obsolete ExcelXP tag set.  Use the ODS Excel destination.  What version of SAS are you running?  Unless it's a fairly old version, you should be able to use the Excel destination.  If you use the Excel destination, then you don't need to convert XML to XLSX; you'll have XLSX directly.

 

This paper might be helpful:

https://blogs.sas.com/content/sgf/2017/02/20/tips-for-using-the-ods-excel-destination/

 

Jim

jimbarbour
Meteorite | Level 14

@jimbarbour wrote:

Why not just go straight to Excel (xlsx)?  Don't use the essentially obsolete ExcelXP tag set.  Use the ODS Excel destination.  What version of SAS are you running?  Unless it's a fairly old version, you should be able to use the Excel destination.  If you use the Excel destination, then you don't need to convert XML to XLSX; you'll have XLSX directly.

 

This paper might be helpful:

https://blogs.sas.com/content/sgf/2017/02/20/tips-for-using-the-ods-excel-destination/

 

Jim


You might consider my suggestion of just going directly to XLSX and eliminating the XML step.  Going directly to XLSX can be fully automated.

 

Jim

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