See this short example:
data pnq;
input abc $ xyz $ dep $ sal;
datalines;
A A xxx 1
A A xxx 2
A A Y 5
B B xxx 6
B B Z 7
;
PROC SQL;
SELECT ABC,XYZ, DEP,Sum(SAL)as Sal
from PNQ
where DEP='xxx'
group by ABC,XYZ;
Quit;
Log from the SQL:
84 PROC SQL;
85 SELECT ABC,XYZ, DEP,Sum(SAL)as Sal
86 from PNQ
87 where DEP='xxx'
88 group by ABC,XYZ;
NOTE: The query requires remerging summary statistics back with the original data.
89 Quit;
Result:
abc xyz dep Sal
A A xxx 3
A A xxx 3
B B xxx 6
As you can see, you get two lines for the first group, instead of only one with the sum. Is this your intention?
No matter what, a result like this with a row number can be done with PROC PRINT. A dataset with a running count is done best in a data step.
Maxim 14: Use the Right Tool.
Most often, SQL is NOT the right tool.
For more help, please supply example data in a data step with datalines (see my code example), and show the exact expected result from this, and declare if you want a report or a dataset.
... View more