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

I am trying to read a XLSX file that is "compressed" in Windows 10 I assume WinZip.   When I point to it I get: Insufficient authorization to access error

 

filename in1 zip 'C:\myzipfile.zip' ;

data _null_;
infile in1;
input;
put _infile_;
run;

1 ACCEPTED SOLUTION

Accepted Solutions
Tom
Super User Tom
Super User

You cannot read an XLS file like it was text.  You could try to read it as binary data, but it wouldn't make sense to do that.  Instead use PROC IMPORT to convert on of the sheets in the XLS file into a SAS dataset.

You could try using your fileref of IN1 with PROC IMPORT,

filename in1 ZIP 'C:\health.zip' member="myhealth.xls" recfm=f lrecl=512;
proc import datafile=in1 dbms=xls out=myhealth replace;
run;

but I suspect that you will have to copy the file out of the ZIP into a real physical file and point PROC IMPORT at that physical file instead.  You could use a temporary file.

filename in1 ZIP 'C:\health.zip' member="myhealth.xls" recfm=f lrecl=512;
filename copy temp recfm=f lrecl=512;
data _null_;
  rc=fcopy('in1','copy');
  put rc=;
run;

proc import datafile=copy dbms=xls out=myhealth replace;
run;
proc contents data=myhealth;
run;

 

View solution in original post

7 REPLIES 7
Kurt_Bremser
Super User

Do you have a standalone SAS installation, or do you work in a client/server environment? If the latter, you can't access your desktop drive like this.

asabou01
Obsidian | Level 7

No it is a network drive (client/server)

Kurt_Bremser
Super User

C: is NOT a network share. It is always the local disk from which Windows was started.

I was NOT asking about your disk drives, I was asking about your SAS installation. Be precise in your wording.

asabou01
Obsidian | Level 7

Sorry about "misspeaking" on my part.   Windows 10 SAS installed on local PC.  I added a "member" and I was able to read it.   

 

The member is in XLS format and not newer EXCEL version (XLSX).   Do I need now to define all columns in XLS file in a datastep? I have been using "Proc Import" after un-compressing the file in the past. Thanks very much!

filename in1 ZIP 'C:\health.zip' member="myhealth.xls";

data be;
infile in1;
input;
run;

 

 

Tom
Super User Tom
Super User

You cannot read an XLS file like it was text.  You could try to read it as binary data, but it wouldn't make sense to do that.  Instead use PROC IMPORT to convert on of the sheets in the XLS file into a SAS dataset.

You could try using your fileref of IN1 with PROC IMPORT,

filename in1 ZIP 'C:\health.zip' member="myhealth.xls" recfm=f lrecl=512;
proc import datafile=in1 dbms=xls out=myhealth replace;
run;

but I suspect that you will have to copy the file out of the ZIP into a real physical file and point PROC IMPORT at that physical file instead.  You could use a temporary file.

filename in1 ZIP 'C:\health.zip' member="myhealth.xls" recfm=f lrecl=512;
filename copy temp recfm=f lrecl=512;
data _null_;
  rc=fcopy('in1','copy');
  put rc=;
run;

proc import datafile=copy dbms=xls out=myhealth replace;
run;
proc contents data=myhealth;
run;

 

asabou01
Obsidian | Level 7

Thank you so much!

Tom
Super User Tom
Super User

A ZIP file is like a directory. What file inside the ZIP file are you trying to read? You need to specify the member name. Either in the FILENAME statement or the INFILE statement.

https://documentation.sas.com/?docsetId=lestmtsglobal&docsetTarget=n1dn0f61yfyzton1l2ngsa1clllr.htm&...

If it is an XLSX file then you will need to first copy it out to an actual file for the XLSX libname engine to work on it.

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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
  • 7 replies
  • 2309 views
  • 1 like
  • 3 in conversation