BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
geneshackman
Pyrite | Level 9

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

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
ballardw
Super User

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.

 

View solution in original post

4 REPLIES 4
PaigeMiller
Diamond | Level 26
proc summary data=have nway;
    class county;
    var yourvarname;
    output out=want sum=;
run;
--
Paige Miller
ballardw
Super User

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.

 

geneshackman
Pyrite | Level 9
Thanks very much!
geneshackman
Pyrite | Level 9

Thanks very much, Ballardw and Paige.

sas-innovate-wordmark-2025-midnight.png

Register Today!

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.


Register now!

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 4 replies
  • 1137 views
  • 2 likes
  • 3 in conversation