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

Hi all. I am looking at hospitalization data and have columns for the county FIPS code that the hospital is in and the number of hospitalizations for a given month and year. I have multiple rows (hospitals) that exist in the same county. I want to sum the total number of hospitalizations per county.

This is what I have:                                                                        This is what I want:

county_fips | month | year | hospitalizations                          county_fips | month | year | hospitalizations_sum

01001                1          2020                 5                                         01001                1          2020                 15

01001                1          2020                 10                                       01001                2          2020                 6

01001                2         2020                  6                                        01002                1          2020                 10

01002                1          2020                 6

01002                1          2020                 4

 

I am at a loss for how to make this happen. Any help is appreciated! 

1 ACCEPTED SOLUTION

Accepted Solutions
PaigeMiller
Diamond | Level 26

PROC SUMMARY is the perfect tool for this

 

proc summary data=have nway;
    class county_fips month year;
    var hospitalizations;
    output out=want sum=hospitalizations_sum;
run;
--
Paige Miller

View solution in original post

2 REPLIES 2
PaigeMiller
Diamond | Level 26

PROC SUMMARY is the perfect tool for this

 

proc summary data=have nway;
    class county_fips month year;
    var hospitalizations;
    output out=want sum=hospitalizations_sum;
run;
--
Paige Miller
joachimg
Obsidian | Level 7

This is awesome. Thank you so much. My boss and I thank you. xD

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
  • 2 replies
  • 750 views
  • 1 like
  • 2 in conversation