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;
%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);
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.
@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.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.