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

Hi all,

 

I am having problems trying to mass import a number of monthly XLSX files into SAS.

 

I have tried the below script but getting an error:

proc import datafile="Location\Apr15.xlsx"
out=apr15 dbms=xlsx
replace;
run;

 

Error Log:

DBMS type XLSX not valid for import

 

Both of my SAS (9.4) and Excel (2016) are 64 bit.

 

The other thing I have tried is to mass convert the XLSX files into CSV first using a batch program but I am losing the leading zeros from a number of key variables.

 

What do you suggest?

 

Cheers,

Pete

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User

Do you have a license for SAS/ACCESS to PC Files?

If not, then you don't have the appropriate tools to do this.

 

Check installed products:

proc product_status;run;

Check licensed products:

proc setinit;run;

@PetePatel wrote:

Hi all,

 

I am having problems trying to mass import a number of monthly XLSX files into SAS.

 

I have tried the below script but getting an error:

proc import datafile="Location\Apr15.xlsx"
out=apr15 dbms=xlsx
replace;
run;

 

Error Log:

DBMS type XLSX not valid for import

 

Both of my SAS (9.4) and Excel (2016) are 64 bit.

 

The other thing I have tried is to mass convert the XLSX files into CSV first using a batch program but I am losing the leading zeros from a number of key variables.

 

What do you suggest?

 

Cheers,

Pete


If your conversion is going wrong, try a different approach. There's a VBS script on the SAS Support page that could be easily modified. Typically Excel is the one that removes the leading zeroes while trying to be helpful.

View solution in original post

2 REPLIES 2
Reeza
Super User

Do you have a license for SAS/ACCESS to PC Files?

If not, then you don't have the appropriate tools to do this.

 

Check installed products:

proc product_status;run;

Check licensed products:

proc setinit;run;

@PetePatel wrote:

Hi all,

 

I am having problems trying to mass import a number of monthly XLSX files into SAS.

 

I have tried the below script but getting an error:

proc import datafile="Location\Apr15.xlsx"
out=apr15 dbms=xlsx
replace;
run;

 

Error Log:

DBMS type XLSX not valid for import

 

Both of my SAS (9.4) and Excel (2016) are 64 bit.

 

The other thing I have tried is to mass convert the XLSX files into CSV first using a batch program but I am losing the leading zeros from a number of key variables.

 

What do you suggest?

 

Cheers,

Pete


If your conversion is going wrong, try a different approach. There's a VBS script on the SAS Support page that could be easily modified. Typically Excel is the one that removes the leading zeroes while trying to be helpful.

ballardw
Super User

It appears that you may not have the SAS/Access Interface to PC Files module available.

 

I would actually go the CSV route with some addition. Use Proc Import to import one of the CSV files. The log will contain data step code used to read the file. Copy that data step from the log to the editor. Save it. Modify the data step code insure that the lengths of character variables are sufficient across all of your expected data, that the informats are correct (date instead of character or character instead of numeric such as your leading zero variable).

 

Then rerun the data step with corrections until you like the result. You could then read each file separately changing the infile statement to point to the different file and the output data set.

The are a number of posts on this forum for how to read multiple sets.

 

Depending on how your Excel files were created it is possible that your CSV will have "ghost" rows of data with all variables missing, so you may need to address that.

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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
  • 2 replies
  • 6999 views
  • 3 likes
  • 3 in conversation