Exporting unix parameter to sas datastep

Reply
Contributor
Posts: 30

Exporting unix parameter to sas datastep

Hi ,

 

Can i know how to export unix variable to sas datastep.Im executing below code:

 

data _null_;
X "cat /cis01/whlbio/WHL_BIO_PRODUCTION/WHL_BIO_PAIDOUT_OBLN_404_OPSRISK/logs/Paidout_obln_production_script.log |grep ^ERROR:* > /cis01/whlbio/WHL_BIO_PRODUCTION/WHL_BIO_PAIDOUT_OBLN_404_OPSRISK/logs/xx.dat";
X "count=cat /cis01/whlbio/WHL_BIO_PRODUCTION/WHL_BIO_PAIDOUT_OBLN_404_OPSRISK/logs/xx.dat|wc -l";
run;

 

I want to export count parameter to sas macro variable. 

 

i used below file name pipe, but  can able to see the result in the sas eg frontend but not in batch execution. any idea why ? 

 

filename temp pipe "cat /cis01/whlbio/WHL_BIO_PRODUCTION/WHL_BIO_PAIDOUT_OBLN_404_OPSRISK/logs/xx.dat|wc -l";

data temp1;
infile temp;
input count 2.; /** read the result of the wc command **/
run;

Super User
Posts: 6,642

Re: Exporting unix parameter to sas datastep

%SYSGET is the usual SAS tool for retrieving the value of a Unix environmental variable into a SAS macro variable.  Within a SAS program (for example):

 

%let SAS_macro_varname = %SYSGET(Unix_env_varname);

Contributor
Posts: 30

Re: Exporting unix parameter to sas datastep

Posted in reply to Astounding

I tried this but im getting below warning:

data _null_;
X "cat /cis01/whlbio/WHL_BIO_PRODUCTION/WHL_BIO_PAIDOUT_OBLN_404_OPSRISK/logs/Paidout_obln_production_script.log |grep ^ERROR:* > /cis01/whlbio/WHL_BIO_PRODUCTION/WHL_BIO_PAIDOUT_OBLN_404_OPSRISK/logs/xx.dat";
X "count=cat /cis01/whlbio/WHL_BIO_PRODUCTION/WHL_BIO_PAIDOUT_OBLN_404_OPSRISK/logs/xx.dat|wc -l";
run;

%let count1=%sysget(count);
%put &count1.;
WARNING: The argument to macro function %SYSGET is not defined as a system variable.

Super User
Posts: 13,358

Re: Exporting unix parameter to sas datastep


Deepti44 wrote:

Hi ,

 

Can i know how to export unix variable to sas datastep.Im executing below code:

 

data _null_;
X "cat /cis01/whlbio/WHL_BIO_PRODUCTION/WHL_BIO_PAIDOUT_OBLN_404_OPSRISK/logs/Paidout_obln_production_script.log |grep ^ERROR:* > /cis01/whlbio/WHL_BIO_PRODUCTION/WHL_BIO_PAIDOUT_OBLN_404_OPSRISK/logs/xx.dat";
X "count=cat /cis01/whlbio/WHL_BIO_PRODUCTION/WHL_BIO_PAIDOUT_OBLN_404_OPSRISK/logs/xx.dat|wc -l";
run;

 

I want to export count parameter to sas macro variable. 

 

i used below file name pipe, but  can able to see the result in the sas eg frontend but not in batch execution. any idea why ? 

 

filename temp pipe "cat /cis01/whlbio/WHL_BIO_PRODUCTION/WHL_BIO_PAIDOUT_OBLN_404_OPSRISK/logs/xx.dat|wc -l";

data temp1;
infile temp;
input count 2.; /** read the result of the wc command **/
run;


Your EG sessions and the batch environment may be running with different permissions and I can't tell if the path your are using is relative or absolute but from where the batch environment executes the path may not be accessible.

 

What does the log of the batch job look like. Paste the relevant section with the filename and data step plus any notes, warnings and errors into a code box opened in the forum using the {I} icon at the top of the message window. The code box helps because there are often diagnostic characters in the error messages but the main message windows on this forum will reformat text moving them from the position of the error.

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