Should be very simple. I want to sum rows, so instead of each county having two rows, by group 1 and group 2, I get one row by county, with sum, within each county, of group1 and group2. I'm sure it's simple, but I could use help. Thanks very much.
countyA | Group1 | 23 |
countyA | Group2 | 14 |
CountyB | Group1 | 34 |
CountyB | Group2 | 10 |
CountyC | Group1 | 12 |
CountyC | Group2 | 18 |
CountyD | Group1 | 10 |
CountyD | Group2 | 12 |
CountyA | sum | 37 |
CountyB | sum | 44 |
CountyC | sum | 30 |
CountyD | sum | 22 |
Do you want a data set or a report for people to read:
Proc summary data=have nway; class countynamevariable; var numbertoaddvariablename; output out=want (drop=_type_ _freq_) sum=; run;
the drop removes some automatic variables that describe the data.
Note if you have multiple variables to sum (or get a mean, std deviation, max, min median) add them to the VAR statement.
proc summary data=have nway;
class county;
var yourvarname;
output out=want sum=;
run;
Do you want a data set or a report for people to read:
Proc summary data=have nway; class countynamevariable; var numbertoaddvariablename; output out=want (drop=_type_ _freq_) sum=; run;
the drop removes some automatic variables that describe the data.
Note if you have multiple variables to sum (or get a mean, std deviation, max, min median) add them to the VAR statement.
Thanks very much, Ballardw and Paige.
Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.