I'm a bit late to the party, but the behaviour you are seeing is in part a consequence of PROC SQL remerging by default.
You can overcome this globally by setting the option:
OPTIONS NOSQLREMERGE;
Or, on for an individual PROC SQL step:
PROC SQL NOREMERGE;
This combined with what @EtoUspeh mentioned (effectively, use the CALCULATED clause on the output fields in the SELECT statement).
For those that are from an SQL background, the SQLREMERGE option means that you can use aggregate functions without a GROUP BY clause. For example, this is valid in SAS, but not in ANSI SQL:
PROC SQL REMERGE;
SELECT id, COUNT(*) FROM tmp;
QUIT;
Editor's note: added the doc links for completeness.
For performance tuning, the SAS doc provides guidance on when you might want to disable REMERGE:
Disabling the Remerging of Data When Using Summary Functions
When you use a summary function in a SELECT clause or a HAVING clause, PROC SQL might remerge the data. Remerging the data involves two passes through the data. If you set the PROC SQL NOREMERGE option or the NOSQLREMERGE system option, PROC SQL will not process the remerging of data. When referencing database tables, performance is enhanced because it enables more of the query to be passed down to the database.
... View more