BookmarkSubscribeRSS Feed
hwangnyc
Quartz | Level 8

Hi All,

 

I'm trying to export a dataset to a excel file that has a password protect feature enabled. Here is the code that I am using:

PROC EXPORT DATA = contactOUT
OUTFILE = "S:\counselor.xlsx"
DBMS=xlsx REPLACE;
Sheet = "Counselor";
QUIT;

I get this error when I try to run it:

 

Error creating XLSX file -> S:\CommunityHealth\DPHO-Harlem\Research, Evaluation, and
Planning\Henry\EHACE\Reports\CHE Monthly Report\counselor.xlsx . It is either not an Excel
spreadsheet or it is damaged. Error code=8014900A
Requested Output File is Invalid

ERROR: Export unsuccessful. See SAS Log for details.

 

Any way to input the password into the code so it can write to it?

 

Thanks!

6 REPLIES 6
RW9
Diamond | Level 26 RW9
Diamond | Level 26

It is nothing to do with the password protected Excel file as far as I can see, the password is only on opening the file that it is a problem, and you have specified REPLACE, so it should just overwrite what is there, assuming you have permission to write there, and that path exists and has no special characters in.  I suspect that you dont have access to that area, or something similar, what software are you using - is it Enterprise Guide, Visual Analytics, University Edition etc?  For UE, you paths should be unix style and relative.

 

Also to note in any circumstance the path:

S:\CommunityHealth\DPHO-Harlem\Research, Evaluation, and Planning\Henry\EHACE\Reports\CHE Monthly Report\counselor.xlsx

Is really not to be recommended.  Paths really should not contain spaces, special characters (such as commas) as this just causes problems for programmers.

hwangnyc
Quartz | Level 8
Hi RW9,

Thanks for the tips, especially with the filenames. But I think the password protect is causing the issue. When I remove the password from the excel file it outputs just fine. I think the replace option is for replacing the SHEET and not the file.
RW9
Diamond | Level 26 RW9
Diamond | Level 26

Ah yes, looking at the SAS guidance:

http://support.sas.com/kb/20/923.html

It does seem like it will try to replace the named range if it exists.  Well, from memory, no you can't do much with a password protected Excel file.  but you could just use the fdelete command to delete the file before exporting:

http://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/viewer.htm#a000245893.htm

LinusH
Tourmaline | Level 20
Just don't use password protected files in BI solutions, it just cause headache and are not particularly safe. Find other means to protect your data.
Data never sleeps
hwangnyc
Quartz | Level 8

Thanks for the response. Do you have any suggestions as to how to better protect the information if I remove the password? I export this data out to the excel file on a daily basis and only want a select number of people to be able to view the file. It's more a safe guard that someone does not accidently open the file being exposed to the information. 

RW9
Diamond | Level 26 RW9
Diamond | Level 26

Don't use Excel full stop.  Totally unvalidated, unsafe, unstructured file format.  Publish your results to an access restricted web address, Sharepoint for example.  Use PDF or something to make it hard to edit.

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
  • 5441 views
  • 0 likes
  • 3 in conversation