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.
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
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.