I have following data. I would really appreciate if you can help me to get weekly number of deaths by age group across the years.
date_of_death age_cat
2012-08-16 1
2012-08-27 2
2013-08-29 3
2019-07-21 4
I want the following.
Year week deaths_count
2012 1 4
2012 2 2
2013 1 3
2013 2 6
.
2013 52 10
.
.
2019 1 2
Your desired output does not contain age_cat. Please explain.
Thanks for the quick response, i have four age groups: 1, 2, 3, 4
date_of_death age_cat
2012-08-16 1
2012-08-27 2
2013-08-29 3
2019-07-21 4
I want the following.
Year week deaths_count age_cat
2012 1 4 1
2012 2 2 2
2013 1 3 1
2013 2 6 1
.
2013 52 10 3
.
.
2019 1 2
So, please don't make us guess or assume. Give us a complete description of the problem and a complete description or example of what you want.
Your first row in the output table is
Year week deaths_count age_cat
2012 1 4 1
Could your real data also have rows in the output that looks like this?
Year week deaths_count age_cat
2012 1 7 2
2012 1 1 3
Also, is date_of_death a numeric variable or a character variable?
Thank you again,
I am looking an output table in the following format. Also, date_of_death is in numeric format
Year week deaths_count age_cat
2012 1 20 1
2012 2 18 1
2012 3 16 1
. . . .
. . . .
2012 52 10 2
2012 1 20 2
2012 2 18 2
2012 3 16 2
. . . .
. . . .
2012 52 10 2
2013 1 20 1
2013 2 18 1
2013 3 16 1
. . . .
. . . .
2013 52 10 1
/* UNTESTED CODE */
proc freq data=have;
tables date_of_death*agecat/list;
format date_of_death yyweeku7.;
run;
Thank you so much, it did work. I am wondering if it is possible to get the output table in the following format. Sorry, i am a naive user
Year week deaths_count age_cat
2012 1 20 1
2012 2 18 1
2012 3 16 1
. . . .
. . . .
2012 52 10 2
2012 1 20 2
2012 2 18 2
2012 3 16 2
. . . .
. . . .
2012 52 10 2
2013 1 20 1
2013 2 18 1
2013 3 16 1
. . . .
. . . .
2013 52 10 1
What is it specifically that you want to change from the output of my program?
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.