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 🙂
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
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
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).
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
@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?
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.
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.
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 16. Read more here about why you should contribute and what is in it for you!
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.
Select SAS Training centers are offering in-person courses. View upcoming courses for: