I am trying to unzip a bundle of zip files from SAS. But without luck. No errors but also no output.
Can you help me with the code? Log is showed below.
Thanks in advance.
Here is my Code:
filename tmp pipe 'dir "e:\SASFolders\DW\Data\*.zip" /b';
%let Win_path =C:\Program Files\7-Zip\7z.exe;
%let path =e:\SASFolders\DW\Data;
filename tmp pipe 'dir "e:\SASFolders\DW\Data\*.zip" /b';
data _null_;
infile tmp;
length nm $200;
input nm $;
call execute(cat('x "&Win_path." e &path.',strip(nm),';'));
run;
log file:
30 filename tmp pipe 'dir "e:\SASFolders\DW\Data\*.zip" /b';
33
34 %let Win_path =C:\Program Files\7-Zip\7z.exe;
35 %let path =e:\SASFolders\DW\Data ;
36
37 filename tmp pipe 'dir "e:\SASFolders\DW\Data\*.zip" /b';
38
39 data _null_;
40 infile tmp;
41 length nm $200;
42 input nm $;
43 call execute(cat('x "&Win_path." e &path.',strip(nm),';'));
44 run;
NOTE: The infile TMP is:
Unnamed Pipe Access Device,
PROCESS=dir "e:\SASFolders\DW\Data\*.zip" /b,
RECFM=V,LRECL=32767
NOTE: 3 records were read from the infile TMP.
The minimum record length was 62.
The maximum record length was 62.
NOTE: DATA statement used (Total process time):
real time 0.04 seconds
cpu time 0.00 seconds
2 The SAS System 12:10 Wednesday, October 14, 2020
NOTE: CALL EXECUTE generated line.
1 + x "C:\Program Files\7-Zip\7z.exe" e
e:\SASFolders\DW\Data\d1c18e01-6e04-47ef-99a1-1bf5fd01c760.zip
1 +
;
2 + x "C:\Program Files\7-Zip\7z.exe" e
e:\SASFolders\DW\Data\d1c18e01-6e04-47ef-99a1-1bf5fd01c760.zip
2 +
;
3 + x "C:\Program Files\7-Zip\7z.exe" e
e:\SASFolders\DW\Data\20201012_d1c18e01-6e04-47ef-99a1-1bf5fd01c760.zip
3 +
;
45
46 %LET _CLIENTTASKLABEL=;
47 %LET _CLIENTPROCESSFLOWNAME=;
48 %LET _CLIENTPROJECTPATH=;
49 %LET _CLIENTPROJECTPATHHOST=;
50 %LET _CLIENTPROJECTNAME=;
51 %LET _SASPROGRAMFILE=;
52 %LET _SASPROGRAMFILEHOST=;
53
54 ;*';*";*/;quit;run;
55 ODS _ALL_ CLOSE;
56
57
58 QUIT; RUN;
Make a slight change:
fvar = catx(" ",quote("&Win_path."),"e &path."!!strip(nm));
In this statement:
call execute(cat('x "&Win_path." e &path.',strip(nm),';'));
The use of the single quotes prevents resolving of the macro variable.
You should split that into two steps; first, create a dataset with filenames:
filename tmp pipe 'dir "e:\SASFolders\DW\Data\*.zip" /b';
data fnames;
infile tmp;
length nm $200;
input nm $;
run;
Next, use the "Dynamic Pipe" to execute your commands:
data _null_;
set fnames;
length fvar $300;
fvar = catx(" ",quote("&Win_path."),"e &path.",strip(nm));
infile dummy pipe filevar=fvar end=done;
do until(done)
input;
put _infile_;
end;
run;
This should return all system responses to the log.
it is a nice soluation. but i can not see the output ? it is not unpacked to the source directory. Do you know where it is stores or can I set an output directory?
the response from running is this:
Extracting archive: e:\SASFolders\BUFDW\Data\01_Source_Data\85_AULA\auladata_101_20201012_d1c18e01-6e04-47ef-99a1-1bf5fd01c760.zip
--
Path = e:\SASFolders\DW\Data\d1c18e01-6e04-47ef-99a1-1bf5fd01c760.zip
Type = zip
Physical Size = 16076005
No files to process
Everything is Ok
etc
and there IS two files inside
one of the problem is there is a linefeed in fvar between patch and filename
Make a slight change:
fvar = catx(" ",quote("&Win_path."),"e &path."!!strip(nm));
it WORKS!!! thank you so much.
Now I will find out where the files has been outputted. I suppose the files are in my user default dir. I want to put is somewhere else.
Before you try to run that command from SAS, you should first get it to run from the commandline. It is easier to debug there.
What we know:
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.
Ready to level-up your skills? Choose your own adventure.