Does the source data have multiple observations per UNIQ_ID * INDICATION combination?
If not then the problem a bit easier.
PROC SQL;
CREATE TABLE WORK.WANT AS
SELECT t1.BUCKET
, t1.GROUP
, t1.CODE
, t1.CODE_DESC
, SUM( t1.INDICATOR='IN' ) as IN_UNIQ_ID
, SUM( CASE WHEN t1.INDICATOR='IN' THEN t1.SUM_OF_DOLLARS ELSE . END) AS IN_DOLLARS
, MEAN( CASE WHEN t1.INDICATOR='IN' THEN t1.SUM_OF_DOLLARS ELSE . END) AS IN_AVG_DOLLARS
, SUM( t1.INDICATOR='OUT' ) as OUT_UNIQ_ID
, SUM( CASE WHEN t1.INDICATOR='OUT' THEN t1.SUM_OF_DOLLARS ELSE . END) AS OUT_DOLLARS
, MEAN( CASE WHEN t1.INDICATOR='OUT' THEN t1.SUM_OF_DOLLARS ELSE . END) AS OUT_AVG_DOLLARS
FROM HAVE t1
GROUP BY BUCKET
, GROUP
, IN_FIELD_COUNT DESC
;
QUIT;
PS: Hiding separators at the end of the line, like in your original posting:
Make it really difficult for humans to notice extra (or missing) separators:
It is much easier to just scan down the evenly positioned left side of the lines to check for the separators:
... View more