DATA Step, Macro, Functions and more

Using WinZip command line from inside SAS

Reply
Trusted Advisor
Posts: 1,932

Using WinZip command line from inside SAS

Using this paper, "A Quick Guide to the WinZip® Command Line Add-On", I am trying to use the ideas to obtain a listing of the files inside a specific .zip file. I am running SAS 9.3 on Windows 7 Professional (64 bit).

In that paper, on page 6, is the following example:

%wzzip(

zipfile = C:\WZ_Test\Zipped Text Files.zip

,options = -vb >"C:\WZ_Test\ZipInfo.txt"

);

So, I replace the zipfile option with the location of my exact file; and I replace the options= with the location where I want the text file to be, and I run the SAS code. It doesn't work, and I get no error messages in the SASLOG or anywhere else. The desired output file doesn't show up. (Note: in Win 7 64 bit, the WZZIP.exe command is in the location C:\Program Files (x86) instead of C:\Program Files, but I have corrected the code for that).

In the SASlog, there is actual DOS code generated that can be copied and pasted into a DOS window. So, I try that, and the command works in DOS.

So I conclude that there is something in SAS and/or Windows 7 that is preventing the code from executing properly inside SAS. But I have no idea what, or where to look. I welcome your suggestions.

Super User
Super User
Posts: 7,076

Re: Using WinZip command line from inside SAS

Posted in reply to PaigeMiller

Your filename has embedded spaces.  Try quoting it.  (or have the macro do it)  The QUOTE function is good for this.

Another issue I have had with other programs is that environment variables are different when run from command shell than when running from within SAS.

Trusted Advisor
Posts: 1,932

Re: Using WinZip command line from inside SAS

Tom wrote:

Your filename has embedded spaces.  Try quoting it.  (or have the macro do it)  The QUOTE function is good for this.

Another issue I have had with other programs is that environment variables are different when run from command shell than when running from within SAS.

My file name does not have space(s) in it, and quoting or not doesn't seem to make a difference.

I don't understand the comment and environment variables, how could I find the environment variables used in the command shell?

Super User
Super User
Posts: 7,076

Re: Using WinZip command line from inside SAS

Posted in reply to PaigeMiller

Sure looks like a space between the d and the T and another between the t and the F.

From the command line you might need to enclose that filename in quotes to prevent the parse from thinking it was either multiple files or command parameters.

wzzip -vb "C:\WZ_Test\Zipped Text Files.zip"

Similarly the path the directory with the wzzip executable might have embedded spaces.

Trusted Advisor
Posts: 1,932

Re: Using WinZip command line from inside SAS

Tom, that's the example in the paper with the spaces. Trust me, there are no spaces in my files names.

I will check the environment variables as you suggest.

Super User
Super User
Posts: 7,076

Re: Using WinZip command line from inside SAS

Posted in reply to PaigeMiller

You can use the set command with no arguments to get a list of the environment variables.

One example that I had problems with environment variables was on a Unix system.  A program that I wanted to call from within SAS assumed that the environment variable TEMP pointed to a directory where it could store temporary files.  But the script that I was using to run SAS had already used that environment variable to point to a file instead of a directory.  So I had to include an unset TEMP command in the command string that I called from within SAS to get the program to run properly.

Super User
Posts: 10,046

Re: Using WinZip command line from inside SAS

Posted in reply to PaigeMiller

Could you use filename + pipe ?

Ask a Question
Discussion stats
  • 6 replies
  • 1107 views
  • 0 likes
  • 3 in conversation