BookmarkSubscribeRSS Feed
kumarsandip975
Quartz | Level 8

Hi,

 

I am running proc import with proc https to make connection to SharePoint site from sas. I am trying to import file.docs from SharePoint to SAS , I am able to import successfully docs file, but getting following ERROR: message and I think that is obvious as proc import has I guess limitation to read only xlsx/csv etc. file format. Not really .docs/.ppt etc. 

 

But since , my purpose is here to import the unsupported format like docs/ppt etc. from SharePoint to SAS, and it is happening correctly. I just need to suppress the following ERROR from the log, so that it does not create confusion to users. 

 

Could you please suggest on it, how to suppress this particular error message, not every other ERROR message. 

 

Also, I just wanted to check if there is any possibilities to import all kind of format files through proc import.

 

filename fileout "D:Sharepoint\file.docs";
proc http url="https://graph.microsoft.com/v1.0/me/drives/&driveId./items/&fileId./content"
oauth_bearer="&access_token"
out = fileout;
run;
filename sample temp;
proc import file=fileout
out=sample
dbms=xlsx replace;
run;

 

ERROR: Error opening XLSX file -> E:\SAS Temporary Files\_TD12345_S00ABCDF_\#LN02345. . It is either not an Excel spreadsheet or
it is damaged. Error code=8014900A
Requested Input File Is Invalid
ERROR: Import unsuccessful. See SAS Log for details.
NOTE: The SAS System stopped processing this step because of errors.
9 REPLIES 9
andreas_lds
Jade | Level 19

Importing documents is not possible.

kumarsandip975
Quartz | Level 8

Could you please suggest, how to suppress this particular error message, not every other ERROR message.

kumarsandip975
Quartz | Level 8
As I mentioned in my post, doc file also getting imported on my mentioned destination folder, I also checked the data(doc file), and looks good. That is the only purpose I have as of now, like import data from SharePoint to SAS. So, I just wanted to ignore the ERROR message.
ballardw
Super User

@kumarsandip975 wrote:
As I mentioned in my post, doc file also getting imported on my mentioned destination folder, I also checked the data(doc file), and looks good. That is the only purpose I have as of now, like import data from SharePoint to SAS. So, I just wanted to ignore the ERROR message.

You are using Proc Import to read an XLSX file. Says so right there in your code:

proc import file=fileout
out=sample
dbms=xlsx replace;
run;

The file does not have an XLSX extension. So the procedure very likely doesn't go any further than "extension and dbms type don't match". If the file is actually XLSX, then why does it have a DOCS extension?

 

How exactly did you examine the "doc file" to determine the data looked "good"? Did it open with Excel when you clicked on it? If not, what program did open the file?

 

Reeza
Super User

You need to add a step to your process where you check the extension of the file before you attempt to import it and conditionally run the import. 

 

You're using the term import to mean copy and import of the file but the standard usage is just proc import. 

The  PROC HTTP step will copy any file successfully. Then you should check the extension and only use PROC IMPORT it if it's csv or xlsx.

 

 


@kumarsandip975 wrote:
As I mentioned in my post, doc file also getting imported on my mentioned destination folder, I also checked the data(doc file), and looks good. That is the only purpose I have as of now, like import data from SharePoint to SAS. So, I just wanted to ignore the ERROR message.

 

andreas_lds
Jade | Level 19

@kumarsandip975 wrote:

Could you please suggest, how to suppress this particular error message, not every other ERROR message.


The error can only be suppressed by not trying to import an unsupported file type. This has to happen before proc import is called, but because we don't see the code running before, suggesting a proper fix is impossible.

Tom
Super User Tom
Super User

It is NOT possible convert any random file into a SAS dataset using PROC IMPORT.  In particular you cannot use PROC IMPORT to convert DOC or DOCS file into a dataset.

 

It should be possible to use PROC HTTP retrieve the file from sharepoint and save it somewhere on the machine where SAS is running.  But don't expect to be able to convert it into a dataset.

 

So only run the PROC IMPORT step when the file is something that it makes sense to import.  And then make sure to use the right DBMS= value for the type of file.  For example if the file was a text file with comma separated values you could use DBMS=CSV on the PROC IMPORT step.

 

But also note that if the file actually is an XLSX file then it might have MULTIPLE worksheets.  If you wanted to use PROC IMPORT you would need to convert each sheet to a separate file.  Instead you might want to use the XLSX libref engine instead and copy all of the sheets out of the XLSX file into separate SAS datasets.

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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
  • 9 replies
  • 1861 views
  • 2 likes
  • 6 in conversation