Invoking a summary function to be calculated in a group by or another summary function is not allowed (giving meaning to the error message):
proc sql;
select case when sum(&aq)*price ge mean(sum(&aq)*price) then 'above average'
else 'below average' end as performance,
count(calculated performance) as cont /*not allowed*/
from p1 group by calculated performance /*not allowed*/ ;quit;
Whereas in this case "calculated performance" is calculating a case statement -- not a summary function.
proc sql;
select case when sales ge avg then 'above average'
else 'below average' end as performance, count(calculated performance) as cont /*allowed - performance is a case statement*/
from (select *,sum(&aq)*price as sales,mean(sum(&aq)*price) as avg from p1) group by calculated performance /*allowed - performance is a case statement*/;
quit;
This is why your first query runs when commenting out the group by statement and the count(calculated performance) line.
... View more