I need help with a macro for reading in and combining zip files. There are 100 zip files that I need to read into SAS and combine into one dataset. The filenames are of the form: file-00000data.csv.gz, file-00001data.csv.gz,..., file-00099data.csv.gz The way I have written my macro, Files 00000-00009 need to be handled separately from Files 00010-00099, but I don't now how to create the two cases within the macro. For the first 10 files, the following macro works: data combined_data; set _null_; **empty dataset to add your data to one file at a time; run; %macro unzip_data(filenum); %do i=0 %to &filenum; filename fromzip zip "&wallet.file-0000&i.data.csv.gz" GZIP; data newdata; infile fromzip delimiter = ',' MISSOVER DSD firstobs=2 ; informat id best32. bucket_1 best32. bucket_2 best32.; format id best12. bucket_1 best12. bucket_2 best12.; input id bucket_1 bucket_2; run; data combined_data; set combined_data newdata; run; %end; %mend unzip_data; However, I am having trouble creating the code for handling all of the files (the below code is not working): %macro unzip_data(filenum); %do i=0 %to &filenum; %if i<10 %then %do; filename fromzip zip "&wallet.file-0000&i.data.csv.gz" GZIP; data newdata; infile fromzip delimiter = ',' MISSOVER DSD firstobs=2 ; informat id best32. bucket_1 best32. bucket_2 best32.; format id best12. bucket_1 best12. bucket_2 best12.; input id bucket_1 bucket_2; run; data combined_data; set combined_data newdata; run; %end; %else %do; filename fromzip zip "&wallet.file-000&i.data.csv.gz" GZIP; data newdata; infile fromzip delimiter = ',' MISSOVER DSD firstobs=2 ; informat id best32. bucket_1 best32. bucket_2 best32.; format id best12. bucket_1 best12. bucket_2 best12.; input id bucket_1 bucket_2; run; data combined_data; set combined_data newdata; run; %end; %end; %mend unzip_data;
... View more