BookmarkSubscribeRSS Feed
saslearner3
Fluorite | Level 6

Hi, 

  I am using code mentioned below to importing a csv file directly from a zip file and the code is working fine, but when i apply the same code on password protected zip file it doesnt work. Is there anyway i can get this to work by mentioning password some where in the code. Any other method would also be appreciated 

 


FILENAME ZIPFILE zip 'K:\check1.zip' ;
DATA newdata ;
INFILE ZIPFILE(new.csv)
DLM = ','
MISSOVER
DSD
LRECL = 32767
FIRSTOBS = 1;

informat var1 $ 30. ;

informat var2 $ 30. ;



input var1 $
var2 $
;
RUN;

 

 

Thanks for your help 🙂

8 REPLIES 8
Jagadishkatam
Amethyst | Level 16

There is similar discussion happend on this topic, here is a thread of the same. Hope it helps.

 

https://communities.sas.com/t5/SAS-Procedures/Import-Password-Protected-Text-Files/td-p/101692

 

Thanks,
Jag
saslearner3
Fluorite | Level 6

Hi Jagdishkatam,

 

Thanks for your quick response. Actually i have seen the discussion you posted before posting my question but couldn't get a working solution. There was one solution provided for password protected file but that was for UNIX and i am working on windows OS. Other methods which were mentioned requires additional software installation which i am not allowed to do. Hope this clarifies my query.

 

Thanks

Kurt_Bremser
Super User

The SAS Filename for ZIP does not provide the option to enter a password, so you must use an external means to unzip the archive.

Since there are perfectly working free (as in beer and speech) and currently maintained (de)compression tools available (eg 7-zip), not having them installed is (IMHO) just foolish.

In our organization (large international insurance), 7-zip is installed per default as a standard tool on all desktops (the SAS Server runs on AIX and therefore has compression tools available out of the box). So have your admin install it (or an alternative) on your SAS host (server or desktop).

saslearner3
Fluorite | Level 6

Hi Kurt,

 

Currently i am doing what you have suggested but its's  a lot of manual work as i keep getting these files on regular basis. As you said that FILENAME for ZIP does not accept passwords, is there any other command which does and thus can save me lot of time ?

 

Thanks

Kurt_Bremser
Super User

@saslearner3 wrote:

Hi Kurt,

 

Currently i am doing what you have suggested but its's  a lot of manual work as i keep getting these files on regular basis. As you said that FILENAME for ZIP does not accept passwords, is there any other command which does and thus can save me lot of time ?

 

Thanks


Not within SAS. And if you get such files on a regular basis, you have to set up a process that gets you the necessary passwords so you can do the extract automatically.

Also, if you get such files regularly, your IT people MUST give you the tools needed for your work.

How do you obtain the necessary passwords, anyway?

RW9
Diamond | Level 26 RW9
Diamond | Level 26

Sorry, just wanted to add here, as seen the "getting these files on regular basis".  Why are the files password protected then?  It sounds to me like your using perhaps email or something to send zipped files and then sending password separately - have seen this done a fair bit and its really not secure at all.  ZIP is not a great protection method anyways.  If your doing regular transfers of data then you will be wanting to to use some sort of secure file portal (most companies have these) or SFTP.  Emailing data around is one great way to lose it or worse.

 

Speak to your IT group, they will have something in place.  Forget the whole password protected zips.

RW9
Diamond | Level 26 RW9
Diamond | Level 26

This isn't really a SAS related question.  You recieve a third party file, and then you should follow the process set out in your import process document, aligning with the data transfer document you will have created.  Thus as part of that process, you will store the file somewhere (pull from somewhere, have them post etc. then save to a know location).  Then you would unpack the file, perform routine checks on it, then validate it against your data import agreement.  Then finally move it to production for further processing - hence the further processing shouldn't care about ZIP files or anything like that.  

Balli
Obsidian | Level 7
Hi Saslearner3, I know this is a very old thread but just wondering if you got it working somehow ? I am in a similar situation where we are getting a csv file password protected in a zip.

Thanks

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
  • 8 replies
  • 3567 views
  • 4 likes
  • 5 in conversation