Skip to content
Advertisement

How to add a sum column with respect to a group by

I have a table1 :

And i want to add a column wich sum the count column by grouping the first two variables :

this is what i do :

then :

But i have a feeling this is a sloppy way to do it. Do you know any better ways ? For example with no intermediates tables.

edit : i am using SQL through a proc sql in SAS

Advertisement

Answer

I’m not quite sure if there is a method for a single select statement but below will work without multiple create table statements:

User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement