Can someone please explain the a weird behavior I observe with the ifc function :
I ran the following 3 tests:
data test1;
var = " "; /* 4 spaces */
length outvar $5;
if not missing(var) then outvar = substr(var, 1,5);
else call missing(outvar);
put outvar=;
run;
data test2;
var = " "; /* 4 spaces */
length outvar $5;
outvar = ifc(not missing(var), substr(var, 1, 5), "");
put outvar=;
run;
data test3;
var = " "; /* 5 spaces */
length outvar $5;
outvar = ifc(not missing(var), substr(var, 1, 5), "");
put outvar=;
run;
test1 and test3 run fine. However I get the following warning/note for test2: Invalid third argument to function SUBSTR
While I understand the meaning of this, it is not clear why it is triggered to begin with given it should not go into evaluating that expression in the ifc function. Appears the ifc function is evaluating both expressions regardless of the outcome of logical test.
Aucun commentaire:
Enregistrer un commentaire