Hi,
I would like to create new rows in my dataset that would be based on the sum of other rows. Please note that I'm working with aggregate data.
This is what my dataset looks like:
REGION YEAR SEX TOTAL
1 2017 M 10
2 2017 M 6
3 2017 M 8
1 2017 F 11
2 2017 F 7
3 2017 F 9
1 2018 M 8
2 2018 M 10
3 2018 M 6
1 2018 F 5
2 2018 F 9
3 2018 F 7
I would like to create new rows that would combine all regions together and sum the TOTAL:
REGION YEAR SEX TOTAL
ALL 2017 M 24
ALL 2017 F 27
ALL 2018 M 24
ALL 2018 F 21
Thank you!
Hi,
I would like to add new rows (observations) at the end of my dataset that would be the sum of other rows.
Please note that I'm using aggregate data (not record-level).
Here's what my data looks like:
REGION YEAR SEX TOTAL
1 2017 M 10
2 2017 M 5
3 2017 M 3
1 2017 F 11
2 2017 F 4
3 2017 F 7
1 2018 M 10
2 2018 M 8
3 2018 M 6
1 2018 F 9
2 2018 F 7
3 2018 F 11
What I want is a row at the end combining all the regions together (by sex and year) with the TOTAL sum.
Something like this:
REGION YEAR SEX TOTAL
ALL 2017 M 18
ALL 2017 F 22
ALL 2018 M 24
ALL 2018 F 27
Thank you!
Duplicate thread
DO NOT REPLY HERE
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 lock in 2025 pricing—just $495!
SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.
Find more tutorials on the SAS Users YouTube channel.