Don’t panic: maybe your XLSX file is already opened

This post was kindly contributed by The SAS Dummy - go there to comment and to read the full post.

As you can tell from my recent posts (see here and here), I’ve been working with SAS and Microsoft Excel files quite a bit. I’m really enjoying the ability to import an XLSX file in my 64-bit SAS for Windows without any additional setup.

After one long afternoon of back-and-forth between Excel and SAS, I ran into this alarming error message:

ERROR: Error opening XLSX file -> C:ProjectsMyData.xlsx .  It is either not 
an Excel spreadsheet or it is damaged.   Error code=80001019
Requested Input File Is Invalid
ERROR: Import unsuccessful.  See SAS Log for details.
NOTE: The SAS System stopped processing this step because of errors.
NOTE: PROCEDURE IMPORT used (Total process time):
      real time           0.00 seconds
      cpu time            0.00 seconds

It’s a scary message, and I panicked — but just briefly. I soon remembered that Microsoft Excel likes to place an exclusive file lock on spreadsheet, so if you have it open in Excel, nothing else will be able to read it. My file wasn’t “damaged” — it was simply in use.

I could wish for a better error message like: “Excuse me sir, but it appears that file is already opened by another application. Would you mind closing it so that we can read the data? I mean, whenever it’s convenient for you.”

Once I closed Microsoft Excel and reran my SAS program, all was good. Whew!

tags: excel, proc import, xlsx

The post Don’t panic: maybe your XLSX file is already opened appeared first on The SAS Dummy.

This post was kindly contributed by The SAS Dummy - go there to comment and to read the full post.