I have a strange behavior from SAS. Consider the three following steps: data F1; do nom=1 to 10; x = ceil(ranuni(123)*1000); c = ( ranuni(123) > 0.4 ); output; end; run; proc sql; create table F2 as select nom, (c) as c2, case when calculated c2 > 0 then x**2 else 0 end as x2 from F1; quit; proc sql; create table F3 as select nom, (c)+0 as c3, case when calculated c3 > 0 then x**2 else 0 end as x3 from F1; quit; The step creating F2 generates the error message: ERROR: The following columns were not found as CALCULATED references in the immediate query: c2. But the step creating F3 does not generate an error. My example was simplified. In the real context, variable c would be replaced by a parameter's value, which could be a Boolean expression or a numeric variable. In either case, any value not being zero nor null would trigger a TRUE, otherwise a FALSE. This in principle works with a Boolean condition (which returns 1 for true, and 0 for false), except that PROC SQL does not c2 as a CALCULATED value. In fact, the alternative code proc sql; create table F2 as select nom, (c) as c2, case when c2 > 0 then x**2 /* CALCULATED is not specified! */ else 0 end as x2 from F1; quit; works. The problem is, I want a common codebase for both cases for my parameter. close
... View more