You can't create and resolve a macro variable within the same datastep.
Have you already defined the macro variables ERROR1-ERRORx and PATH1-PATHn and wish to retrieve those values into the datastep based on rownum? i.e. to resolve &&ERROR&ERROR_COUNT
.
If so, just use symexist / symget...
data success error ; length vague 3 path $150 ; set foplist ; if symexist(cats('ERROR',rownum)) and symexist(cats('PATH',rownum)) then do ; error_count = symget(cats('ERROR',rownum)) ; if error_count = 0 then do ; path = symget(cats('PATH',rownum)) ; vague = 1 ; output success ; end ; else output error ; end ; else output error ; run;