Generally the job is using DATA step input/output.
We can also use external file funcitons to handle it, although it is more complex.
%let command = hostname;
data _null_;
length value $ 20;
rc = filename('myfile', "&command", 'PIPE');
fid = fopen('myfile', 'S');
rc = fread(fid);
rc = fget(fid, value, 20);
rc = fclose(fid);
rc = filename('myfile');
put "Command output:" value;
run;
%let filerf=myfile;
%let rc = %sysfunc(filename(filerf, &command, pipe));
%let fid = %sysfunc(fopen(&filerf, S));
%let rc = %sysfunc(fread(&fid));
%let rc = %sysfunc(fget(&fid, value, 20));
%let rc = %sysfunc(fclose(&fid));
%let rc = %sysfunc(filename(filerf));
%put Command output: &value;
No comments:
Post a Comment