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-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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