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!
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;
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;
This is awesome. Thank you so much. My boss and I thank you. xD
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 save with the early bird rate—just $795!
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.