BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
ANLYNG
Pyrite | Level 9

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;

1 ACCEPTED SOLUTION
8 REPLIES 8
Kurt_Bremser
Super User

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.

ANLYNG
Pyrite | Level 9

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?

ANLYNG
Pyrite | Level 9

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

 

ANLYNG
Pyrite | Level 9

one of the problem is there is a linefeed in fvar between patch and filename

ANLYNG
Pyrite | Level 9

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.

Kurt_Bremser
Super User

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:

  • the command is found and executed
  • it finds the archive
  • it seems to not find anything to unzip
ANLYNG
Pyrite | Level 9
is it works from command line but it seems that sas divide the command over two lines -
NOTE: The infile DUMMY is:
Unnamed Pipe Access Device,

PROCESS="C:\Program Files\7-Zip\7z.exe" e e:\SASFolders\DW\Data\
20201013_d1c18e01-6e04-47ef-99a1-1bf5fd01c760.zip,
RECFM=V,LRECL=32767

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 8 replies
  • 887 views
  • 1 like
  • 2 in conversation