12-19-2014 06:20 AM
You need to decompress the file first, there is no functionality at this time to unzip within SAS. You can either do it manually when you receive the file, or pipe an OS command out using x or call system, e.g.:
winzip_path="'c:\programs\winzip\winzip.exe'"; /* Note the double quotes around single quotes */
12-19-2014 06:30 AM
Thanks for quik reply, but every day we received number of files and each compressed file having minimum 5GB,
is there any other option to import into SAS.
12-19-2014 07:51 PM
With SAS 9.4 there is now also a zip engine available which would allow you to read such archives
12-19-2014 09:01 AM
filename oscmd pipe "gzip -dc &infilename";
/* process infile as if unzipped */
This will stream the unzipped contents of the file specified in infilename to your data step.
Consult the proper manuals for other compressed file formats and the correpsonding utilities.
12-20-2014 02:52 AM
I suggest that you do a Google search using "site:support.sas.com filename pipe". Also searching here in this forum with terms like "filename pipe zip" will return quite a few links.
"gzip -dc &infilename"
gzip -dc Is calling the 3rd party GZIP tool with appropriate switches for this tool
&infilename A SAS macro variable which you could define and populate earlier in your code. This is the path and name of your GZIP archive which you pass in as parameter into GZIP
The example is for GZIP. What's the right 3rd party tool for your archive will depend on what's available in your specific environment.
12-22-2014 01:39 AM
-d: decompresses the file (without the -d gzip will do a compression)
-c: instead of writing a compressed/decompressed file, stream the output to stdout
The filename pipe works similar to the reverse apostroph (backtick) under UNIX. The string is executed, and the output is provided to SAS as if you read a file.
The filename pipe is also very useful if you want to include the output and error messages of a command in the SAS log:
filename oscmd pipe "what_you_want_to_execute 2>&1"; * 2>&1 redirects stderr to stdout, so you get everything;
put _infile_; * write the whole input line to the log;
As Patrick suggested, you may need to adapt the command to the zip tool available in your environment. All those tools should have options for batch processing.
12-22-2014 02:22 AM
Thank you one and all,
Here I am receiving minimum 50 compressed files in a week time, and it contains approximate 100 GB.
Every time I used to uncompressed and import flat files into SAS. It consumes huge disc space.
Any way am deleting the all files, once SAS datasets are placed into my libelers.
Thank you very much for your suggestions.
12-22-2014 06:59 AM
Actually, gzip -dc will not use any diskspace at all. So the pipe approach as described only needs the space for the zipped file and the space for the SAS dataset.