%if is macro language, nothing to do with datastep language, they are very different and for different purposes.
If you are making general code for a library or something like that then you will have a functional design specification document which clearly shows all inputs outputs, explains logic, program flow, checks performed etc. So you should have a good idea of the inputs you will get. The cat functions will only concatenate when there is a value present, but that might not cover all eventualities.
Another point, why do you have SCREAS1-x. In standard CDISC models screen fail reasons would be held in SUPPDS domain as:
QNAM QVAL
SCRNREAS ...
And this would only capture where there is data, so to get a complete list of reason you would do:
data want;
set suppds (where=(qnam="SCRNREAS"));
by usubjid;
length reas $2000;
reas=ifc(first.usubjid,qval,catx(';',reas,qval));
if last.usubjid then output;
run;
Or combine that somehow into existing domain modelling code.
... View more