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. 

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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.

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