Help using Base SAS procedures

CALL SYSTEM doesn't work as I expect...

Reply
Contributor
Posts: 72

CALL SYSTEM doesn't work as I expect...

Hi, I ran this code to remotely connect to a server in order to download data and zip it before downloading it to a local PC using SSH File Transfer, but it doesn't give me what I wanted.

%let....
options comamid=....
signon username=_prompt_;
rsubmit;

data _null_;
call system('mkdir /temp/myname);
run;

libname mydata '/temp/myname';

data mydata.something; /*collect data & put it in my directory created above*/
set datasource;
/*codes here*/
run;

/*Things go wrong here*/
data _null_; /*compress data just collected and put it in same directory*/
call system('gzip /temp/myname/something');
run;

After logging in SSH and checking the directory "myname", I saw the file "something" BUT IT IS NOT ZIPPED! The GZIP command wasn't executed in the last SAS codes above. Why so?

Can anyone please help? Thanks a lot
Respected Advisor
Posts: 3,889

Re: CALL SYSTEM doesn't work as I expect...

Hi
If the code you've posted is 1:1 the code you've run with issues then one of the reasons might be that there is a quote missing.

call system('mkdir /temp/myname); ... there should be a quote after .../myname


What I normally do with OS commands: I first try them in a command prompt before I use them in SAS. In your example you could issue the gzip command first in a putty session and see if it works from there.

Else: What does the SAS log tell you?

HTH
Patrick
Contributor
Posts: 72

Re: CALL SYSTEM doesn't work as I expect...

Hi Pattrick, I missed the quote in the codes posted here, but in the original SAS program I have both quotes in the argument to the Call System function.

I've tried the GZIP command in both SSH Secure Shell Client and Putty and it works perfectly. The file is zipped.

The SAS log doesn't say anything about errors. Right below the codes that has the Call System, I saw a few lines like:

"Data statement used (Total process time):
real time 0.17 seconds
cpu time 0.01 seconds"

However, when I logged in SSH I saw data set but it wasn't compressed, meaning the GZIP function wasn't executed.

Thanks a lot for help

Message was edited by: smilingmelbourne Message was edited by: smilingmelbourne
Contributor
Posts: 72

Re: CALL SYSTEM doesn't work as I expect...

I missed the file extension for the SAS dataset, so I didn't work. It should have been........

data _null_;
call system('gzip /temp/myname/something.sas7bdat'); /*Add file extension "sas7bdat and it works"*/
run;
Ask a Question
Discussion stats
  • 3 replies
  • 315 views
  • 0 likes
  • 2 in conversation