Desktop productivity for business analysts and programmers

Infile, Inzip from a shared drive

Accepted Solution Solved
Reply
Contributor
Posts: 69
Accepted Solution

Infile, Inzip from a shared drive

I have a shared drive with a very long name and have mapped to that drive and it happens to be e: There are 12 folders and within the 12 folders there are several zipped files. Using the first folder, I have 3 zipped files. Within the zipped files there are 32 .txt files so in all that would be 96 .txt files. If I take these 12 folders and just try and move them to my local machine, I get a response that it will take 45 hours to move them. On top of that I have to unzip them all and import all the .txt files into SAS. There are a total of 612 .txt files in all. I have to merge all of these into one and then do my coding to manipulate. I tried the following code in SAS to just zipfile them all but I get an error that the location I am pointing to cannot be found. Here is my code:

 

<code>

libname MYTD '/global/users/ad36742/';

filename zipfile zip

'e:\\agpcorp\files\Private\ManagedCareSvcs\Health-QualityMgmt\Hedis Rates_Datasets_Benchmarks\Hedis 2016\Datasets\2016_02_Feb Heids 2016_MY2015\ME1\hedis2016_feb2016_md ssi.zip';

DATA newdata;

INFILE ZIPFILE(MDVBPAmbAdult_exMH_AMBAD16MDb_Detail.txt) dsd DLM = '|';

RUN;

</code>

 

Any advice?


Accepted Solutions
Solution
‎05-03-2016 01:50 PM
Community Manager
Posts: 2,691

Re: Infile, Inzip from a shared drive

Will SAS report the contents of the file for you?  Try:

 

/* Read the "members" (files) from the ZIP file */
data contents(keep=memname);
 length memname $200;
 fid=dopen("inzip");
 if fid=0 then
  stop;
 memcount=dnum(fid);
 do i=1 to memcount;
  memname=dread(fid,i);
  output;
 end;
 rc=dclose(fid);
run;
 
/* create a report of the ZIP contents */
title "Files in the ZIP file";
proc print data=contents noobs N;
run;

View solution in original post


All Replies
Community Manager
Posts: 2,691

Re: Infile, Inzip from a shared drive

I have a couple of notes.

 

First, you realize the filename in the code you supplied has "e:\\" -- 2 slashes.  Intentional?

 

Next, SAS will have to move/read this ZIP file in order to unzip it.  Somehow it's going to have to be read in by your SAS session, so the bandwidth required won't change -- at least relative to your SAS machine (if that's not your local machine).

 

And finally, if you think it's a filename length issue, can you use NET USE: to map a more specific folder down the tree so the name is shorter?

Contributor
Posts: 69

Re: Infile, Inzip from a shared drive

Yes. The \\ appears before all of our mapped drives. I can try taking that out and see if that makes a difference. It did not make a difference. I still get an error opening the file.

 

As far as bandwidth, the 45 hours is simply copying all those files from the shared drive and moving them to my local machine. That has nothing to do with SAS. I was trying to point my SAS session to look at this shared drive and use SAS to unzip and get the files into our library in our SAS EG grid folder. At this time I don't know what the time involved is for that because I cannot get my SAS to even point to the folder correctly.

 

As for Net Use, I don't know what that is so I will have to Google to figure it out. I just thought maybe someone had run into zipped files on a Shared Drive in the past and might know he correct path to put in or way to put it in. So far everyone in my organization has no idea. I am sure there is a way. I cannot imagine SAS would create a software product like SAS Base of PC SAS or SAS EG that does not have the ability to unzip files in a share drive since so many organizations for security purposs store data on shared drives. I have been Googling all day yesterday to find an answer and so far all the information has been how to use SAS to zip your files. That is why I finally posted in the forum hoping to get an answer and stop spending all this time researching since I am running out of time to find an answer.

Community Manager
Posts: 2,691

Re: Infile, Inzip from a shared drive

I've been assuming that when you say E: is a "mapped drive", that means that it's a shorthand reference for a network location that's not on the physical machine where SAS is running.  You can assign mapped drives with something like:

 

net use e: \\myserver\folder1\folder2

 

from a Windows/DOS command prompt.

 

That allows you to then reference a file like:

 

\\myserver\folder1\folder2\myfile.xls

 

as

 

e:\myfile.xls

 

You might need to try a program with a series of FILEEXIST() function calls to see if such a file reference is working at all from your SAS session.  

 

Example:

data a;
 x=fileexist('e:\\agpcorp\files\Private');
run;

X should report as 1, if SAS can see the folder.  Try to go deeper and deeper into the tree to see what works.

 

Contributor
Posts: 69

Re: Infile, Inzip from a shared drive

Yep. Thanks. When I put the exact path in fileexist, it works just fine. It can see the .zip file. When I run my libname and zip file entry alone without the data step, I get no errors. When I add that data step to actually open the .txt file is when the error occurs.

Solution
‎05-03-2016 01:50 PM
Community Manager
Posts: 2,691

Re: Infile, Inzip from a shared drive

Will SAS report the contents of the file for you?  Try:

 

/* Read the "members" (files) from the ZIP file */
data contents(keep=memname);
 length memname $200;
 fid=dopen("inzip");
 if fid=0 then
  stop;
 memcount=dnum(fid);
 do i=1 to memcount;
  memname=dread(fid,i);
  output;
 end;
 rc=dclose(fid);
run;
 
/* create a report of the ZIP contents */
title "Files in the ZIP file";
proc print data=contents noobs N;
run;
Super User
Super User
Posts: 6,304

Re: Infile, Inzip from a shared drive

Are you running SAS on a unix machine?  Look at the value of the automatic macro variable SYSSCP and SYSSCPL if you are not sure.  If you are running on a PC then you can use filename like E:\path\filename or \\server\sharename\path\filename.  But if you are running on Linux then all of you filenames should look lik /path/filename.  

 

If you have a network drive mapped to E: on you PC and your SAS sessions are running on Unix then you need to find out if the Unix machine can see that network drive and what location it is mounted on.  It will not be E:\\.  It will look like a normal unix path.

 

 

 

Contributor
Posts: 69

Re: Infile, Inzip from a shared drive

Yes, it is UNIX so I have to dig around and find the actual path. I wonder if I just open UNIX and type in \\agpcorp or I found the server name of \\va10fsstd003.agp.corp.ads if that will tell me. Because doing the E: or the \\server does not come back in the file exists. I just realized it comes back 0 and not 1 and I know we have to update our UNIX password every 45 days so it is definately UNIX.

 

Community Manager
Posts: 2,691

Re: Infile, Inzip from a shared drive

Your UNIX path is going to use a different structure.  No backslashes, but more like:

 

/r/va10fsstd003/vol/vol001/blah/blah2/andso/on

 

Your IT folks might need to help you translate.

 

Chris

☑ This topic is SOLVED.

Need further help from the community? Please ask a new question.

Discussion stats
  • 8 replies
  • 486 views
  • 0 likes
  • 3 in conversation