08-01-2013 02:53 AM
I am facing an issue in reading zip file. i want to read a zip file and want to place the content of zip file at different location so that i can use that file by data step or other procedures.
can anybody help me to resolve this problem?
My email id is : firstname.lastname@example.org
08-01-2013 03:06 AM
Sometimes data sets are compressed or archived in ZIP files. You can read such a file format directly from SAS without having to decompress the file first. SAS will first unzip the file and then input the data set through the SASZIPAM engine:
FILENAME ZIPFILE SASZIPAM 'C:\Temp\filename.zip';
INFILE ZIPFILE(dataset.csv) DLM=',' FIRSTOBS=2;
INPUT var1 $ var2 $ var3 $ var4;
The FILENAME statement specifies the type of file you wish to unzip (e.g., ZIPFILE), the engine SASZIPAM to be used to decompress the file, and the directory and name of the file to be unzipped (e.g., 'C:\Temp\filename.zip'). The DATA statement names the data set that will be read in (e.g., newdata).
The INFILE statement gives information about the data set within the ZIP file. First, ZIPFILE indicates which file should be unzipped (e.g., dataset.csv), since there may be multiple files in filename.zip. Second, DLM signals which character is used as a delimiter in the data set. Finally, FIRSTOBS indicates that the first line in the data set contains the variable names, and that therefore SAS will begin reading the second line as data. In the INPUT statement, indicate which variable(s) should be transferred to the new data set.
Note: Large compressed data files (e.g.,
.csv formats) are not suited for use with the SASZIPAM engine because they will employ all computer memory and considerably delay all processes. Moreover, the SASZIPAM engine does not decompress all zip files (e.g., zip files created by 7-zip are not compatible). Consider first decompressing the file, and then compressing it with WinZIP, which is compatible with SASZIPAM.
SASZIPAM is available on SAS 9. In addition to data files, you may also use SASZIPAM to unzip log files.
08-01-2013 03:18 AM
Is available wiht 9.4, see: SAS(R) 9.4 Statements: Reference (filename zip)
The other way is using X commands, I prefer the piping method because of synchronisation and output messages, in a way handling the zip with command (dos-box) options. Alle dependends on your system environment (Windows/Unix) and the 3-party tools you have.
Using Zip in this way (one paragraph): http://www2.sas.com/proceedings/forum2008/017-2008.pdf
Fot the fun. most files (docx, srx egp etc) are essential a zip file.
(in addition cross post)
08-01-2013 09:32 AM
As I read the docs for SAS 9.4, it does not appear that this allows you to determine what files are stored in the ZIP file (in other words, read the directory of files contained in the .zip archive, rather than read specific files). Is this possible in SAS 9.4 (or otherwise)?
09-10-2013 02:36 PM
Using DOPEN() and DREAD() seems to work in SAS 9.4; I am able to read the members of a .zip file, but I can only read the member name and not the date or size.
Thus, I still prefer using the macros at:
which allows me to read the member name and member size, even though these macros require downloading an executable file from winzip.com