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.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 16. Read more here about why you should contribute and what is in it for you!
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.
Select SAS Training centers are offering in-person courses. View upcoming courses for: