DATA Step, Macro, Functions and more

Unable to Zip files using X command in Base SAS

Reply
Contributor
Posts: 66

Unable to Zip files using X command in Base SAS

[ Edited ]

Hi All,

 

I am trying to zip a csv file using x command, we have around 10 reports generated using a SAS program and the x command is working for all the 9 reports but it is not working for one of the reports generated. I have cheked the permissions on the folder and the file, and the permissons on the .csv file and the folder is 777.

 

Kindly suggest what am i missing i m using the below code to zip the file once it is created using proc export.

 

x zip /shared/Santosh/annual/publisher_id/ALL_Business_&today.
        /shared/Santosh/annual/publisher_id/ALL_Business_&today..csv;

 

Regards

Santosh...

 

 

 

Super User
Posts: 10,483

Re: Unable to Zip files suing X command in Base SAS

When you use an X command you are asking the operating system to run a program. I suspect that if you have a compression program that it is named something other than Zip. You may also need to provide the path to the executeable depending on your configuration.

 

To test the first open a command prompt and type Zip and see what happens. If you get a message similar to 'zip' is not redognized as an internal or external command, operable program or batch file then you do not have a program named zip and should look for the name of any compression program you may have installed.

Super User
Posts: 6,928

Re: Unable to Zip files using X command in Base SAS

[ Edited ]

Since you did not post any error or other message, I guess you do not get one.

 

Use the following method to catch messages returned by system commands:

filename oscmd pipe "command you want to run 2>&1";

data _null_;
infile oscmd;
input;
put _infile_;
run;

The 2>&1 reroutes stderr (standard error) output to standard output, so you get it in your data step.

After running your command like this, any messages that are returned by the system will appear in the SAS log.

 

Once you have them, and they don't provide a clue to you, post them here.

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
Super User
Super User
Posts: 6,499

Re: Unable to Zip files suing X command in Base SAS

[ Edited ]

If you use a pipe instead of the X command then you can examine any error messages the operating system is trying to send you and that should help you to debug your problem.

 

data _null_;
  infile "zip /shared/Santosh/annual/publisher_id/ALL_Business_&today.
        /shared/Santosh/annual/publisher_id/ALL_Business_&today..csv"
  pipe;
  input;
  put _infile_;
run;
Contributor
Posts: 66

Re: Unable to Zip files suing X command in Base SAS

Hi Tom.

 

Thank you for your quick response,

 

I tried pipe to see what is going on, i got the below eror message:

zip warning: name not matched:

zip error: Nothing to do!

 

i checked the file exists at the location and name of the file is also same.

 

Could you help me on this?

 

Regards,

Santosh

 

Super User
Posts: 6,928

Re: Unable to Zip files suing X command in Base SAS

Do a google search for

zip warning: name not matched:

and follow the links (the stackoverflow ones look quite promising to me), you might get a hint that fits your situation.

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
Super User
Posts: 17,784

Re: Unable to Zip files suing X command in Base SAS

Check your case. The operation may he CASE sensitive. 

Contributor
Posts: 66

Re: Unable to Zip files suing X command in Base SAS

Hi Reeza,

 

Thank you !!!

 

I have checked the Case as well, and both file names and the Case is matching.

Kindly suggest me on this.

Ask a Question
Discussion stats
  • 7 replies
  • 313 views
  • 0 likes
  • 5 in conversation