11-03-2016 10:22 AM - edited 11-03-2016 11:07 AM
I like reading in streams of data like
filename IN1 '.\*.log'; data work.test; attrib filename fn length=$256; retain filename; infile in1 filename=fn eov=eov length=l; input line $varying200. l; if _n_ eq 1 or eov then do; filename = fn; eov = 0; end; run;
and I learned about zip files using
filename inzip zip "&ziploc";
I there a way to read all (similar) data files from a zip file as a stream, like
data allData; infile InZip(*.csv) ...;
11-03-2016 10:38 AM
Sorry, question is a bit unclear. You have a set of CSV files, do you want the CSV files themselves to be added to a ZIP file? Or do you want the datasets you create from reading in the CSV files to be put into a ZIP file? There is a difference. Generally if you have files and want to put them in a zip then you would use the OS to do this (either by select all files and then add to zip or by x commands). If you want the data to a zip, then you can use ods package to create and add files to a zip via SAS per:
11-03-2016 10:43 AM
Have you already taken a look at http://blogs.sas.com/content/sasdummy/2015/05/11/using-filename-zip-to-unzip-and-read-data-files-in-...
I guess there are some hints for you in there.
11-03-2016 11:05 AM
reading it. thanks. Guess there is no way around to copy the csv files out of the zip file and then read them in.
So the set-up is one zip file with a lot of csv-files in that have the same columns.
11-03-2016 11:30 AM
If thats the case, then you would have setup an import process for the zip file would you not? I.e. your data transfer documentation would detail where you will save the ZIP file, how you will ensure the files are all extracted correctly, possibly it will also tell you how you will protect those files - i.e. so if you need to go back to them you can always do this. Hence that data import (and validation) process would take care of getting the files ready, so nothing SAS related, in SAS you would just read in the data.