- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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;
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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;
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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;
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
@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?
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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\";
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
sorry but it didn't work somehow,
%sysexec unzip "d:\test\*.zip" "d:\test\";
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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?
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
yes i can remote server from my local machine, that is how i am accessing server...Also this will be daily script,
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
OK, so what works from a DOS prompt?
Find a working DOS command, then we can make it executable from a SAS program.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
i tried running below command from cmd prompt and its unzipping files,
command exactly looks like this
d:\test>unzip *.zip
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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?
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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.