&SYSRC holds the return code of the last external command executed. But it is not set when a filename pipe is used as input (and therefore runs the command included in the physical name if the fileref).
See this:
filename oscmd pipe "ls /garbage 2>&1";
%put &=sysrc.;
data _null_;
infile oscmd;
input;
put _infile_;
run;
%put &=sysrc.;
x "ls /garbage 2>&1";
%put &=sysrc.;
Log:
27 filename oscmd pipe "ls /garbage 2>&1";
28
29 %put &=sysrc.;
SYsrc=0
30
31 data _null_;
32 infile oscmd;
33 input;
34 put _infile_;
35 run;
NOTE: The infile OSCMD is:
Pipe-Kommando="ls /garbage 2>&1"
ls: 0653-341 The file /garbage does not exist.
NOTE: 1 record was read from the infile OSCMD.
The minimum record length was 46.
The maximum record length was 46.
NOTE: DATA statement used (Total process time):
real time 0.01 seconds
cpu time 0.00 seconds
36
37 %put &=sysrc.;
SYsrc=0
38
39 x "ls /garbage 2>&1"
39 ! ;
40
41 %put &=sysrc.;
SYsrc=2
I therefore suggest that SYSRC is also updated when external commands are run via the filename pipe mechanism, as it would enhance the communication with the host OS.