You will want to read this:
https://v8doc.sas.com/sashtml/lrcon/z0695104.htm
Basically as the datastep runs its loop, it goes line by line into the PDV, _error_ is a variable in that PDV which does not get written to the output dataset. So after the first run; that variable no longer exists. It is created again in the second step, but as there are no errors then the _error_ variable is always false, hence no observations. This will work as the if _error_ is in the same step:
data bad good;
input ID Name$;
if _error_ then output bad;
else output good;
datalines;
121 Kiran
768 Kumar
tyu Raj
;
run;
... View more