BookmarkSubscribeRSS Feed
Shortselling123
Fluorite | Level 6

Hi SAS experts:

 

Is there anyway we can import excels into SAS when excels' format does not match the extension? See attached photo. I can open the excel by simply clicking "yes." 

 

Here is the SAS log:

 

2181 PROC IMPORT OUT=jpmorgan DATAFILE= "C:\Users\Research.xls" DBMS=xls REPLACE;
2181! GETNAMES=YES; RUN;

Spreadsheet isn't from Excel V5 or later. Please open it in Excel and Save as V5 or later
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.01 seconds
cpu time 0.01 seconds

 

Thank you!

 

format not match extension.PNG

4 REPLIES 4
ballardw
Super User

Easiest might be to open the "xls" file in Excel and do a File Save As into a CSV file and import that.

 

Or do a File Save As to XLSX using Excel as recommended by the SAS error message.

Shortselling123
Fluorite | Level 6
Thanks. Unfortunately I have thousands of such excels and it is very time consuming to change format manually.
Reeza
Super User

Then you're best off using a VBS script to convert them all to XLSX. There's a SAS macro on here that does it, see the link below:

 

http://support.sas.com/kb/43/496.html

 

Once they're XLSX you can use PROC IMPORT. If the file formats are the same though, you may want to consider CSV instead. You can change the type by changing the number  and extension on the Excel file Save As command:

 

 mybook.SaveAs ""&default.\"" & Filename & "".xlsx"", 51";

 

CSV looks to be Number 6 instead:

https://msdn.microsoft.com/en-us/vba/excel-vba/articles/xlfileformat-enumeration-excel

 

Hi SAS experts:

 

Is there anyway we can import excels into SAS when excels' format does not match the extension? See attached photo. I can open the excel by simply clicking "yes." 

 

Here is the SAS log:

 

2181 PROC IMPORT OUT=jpmorgan DATAFILE= "C:\Users\Research.xls" DBMS=xls REPLACE;
2181! GETNAMES=YES; RUN;

Spreadsheet isn't from Excel V5 or later. Please open it in Excel and Save as V5 or later
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.01 seconds
cpu time 0.01 seconds

 

Thank you!




Shortselling123
Fluorite | Level 6

That is great. Thank you! Later one friend solved this problem for me by writing some python codes. 

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

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