Hello friends - please help me on how i can unzip files using sas 9.1 on win 2003 server? below code is not working so far,
data _null_;
x unzip "d:\test\*.zip" "d:\test\";
run;
I agree with Patrick ... NOXWAIT is required, and may be all that is missing at this point. If the results are still not successful, I would try breaking the steps into pieces as follows:
options noxwait;
x 'cd d:\test';
x 'dir';
x 'unzip *.zip';
The DIR command isn't really necessary once things are working properly, but it may help diagnose what is happening. I'm hoping this works, because after this I'm out of ideas.
Do you actually have an unzip command installed on your server?
Most unzip commands I have seen can only operate on one zip file at a time so you could not use a wildcard in the name of the zip file.
If you do not know the name of your ZIP file then perhaps you want to first use the DIR command to find the name.
Wrapping the X command with a null data step does nothing for either of them. Try using the PIPE engine on an INFILE statement instead. That way your data step can read any messages that the command generates.
data _null_;
infile "unzip d:\myarchive.zip" pipe ;
input ;
put _infile_;
run;
so can we use wildcard with this? and we will also need to provide destination directory too, right? i tried below code but its not unzipping files - thanks
data _null_;
infile "unzip d:\test\*.zip d:\test\" pipe ;
input ;
put _infile_;
run;
@woo wrote:
so can we use wildcard with this? and we will also need to provide destination directory too, right? i tried below code but its not unzipping files - thanks
data _null_; infile "unzip d:\test\*.zip d:\test\" pipe ; input ; put _infile_; run;
You need to tell use what SAS wrote in the log when you ran that command? Did you get an error that the PIPE engine is not allowed? Did you get an error message from DOS/Windows that the UNZIP command was not found? Did you get an error message from the UNZIP command?
Getting the quotes right with an X command can be tricky. Try switching to %SYSEXEC, which doesn't need as many quotes:
%sysexec unzip "d:\test\*.zip" "d:\test\";
sorry but it didn't work somehow,
%sysexec unzip "d:\test\*.zip" "d:\test\";
Have you tried the simple version? This is the sort of command I would expect to work.
Directly:
unzip d:\test\*.zip
From SAS:
%sysexec unzip d:\test\*.zip;
Which command works directly from the operating system when you are not trying to add SAS to the mix?
Can you remote desktop onto your server? It's normally easiest to get the zip command right out of a dos prompt and only then incorporate it into SAS.
Hi,
What is the purpose - i.e. are you trying to create some sort of automation? Describe the scenario, will this be a once off, routine, what happens to existing files, how do you want to handle exceptions etc. If its a once off then there is no point coding it. If it is a routine automation, then speak to your IT group who will likely have some sort of ftp + unpack script and should be able to help with setting it up.
yes i can remote server from my local machine, that is how i am accessing server...Also this will be daily script,
OK, so what works from a DOS prompt?
Find a working DOS command, then we can make it executable from a SAS program.
i tried running below command from cmd prompt and its unzipping files,
command exactly looks like this
d:\test>unzip *.zip
Assuming that you re-zip a file or two in that folder, what happens when you try either of these:
x 'unzip d:\test\*.zip';
%sysexec unzip d:\test\*.zip;
Do you get an error message? Does nothing happen?
I ran both command one by one and for both command line its prompting 2 windows, "The SAS system x command window is active" window and "cmd command prompt" windows. sas system x command window saying - the X command is active. Enter EXIT at the promt in the X command window to reactivate this SAS session.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.
Find more tutorials on the SAS Users YouTube channel.