BookmarkSubscribeRSS Feed
epi_user
Calcite | Level 5

I have a dataset that has many age categories by race and I am interested in combining all age categories in each race in each county to create a "total" variable for each county . 

 

thank you! 

 

I'd like the final data to look like this: 

 County Race Age _2020

xAsi15-1965
xAsi20-2434
xAsi25-2945
xAsiTotal144
yAsi15-1916
yAsi20-249
yAsi25-2913
yAsiTotal38

 

the original data looks like this: 

County Race Age _2020
xAsi15-1965
xAsi20-2434
xAsi25-2945
yAsi15-1916
yAsi20-249
yAsi25-2913
2 REPLIES 2
PaigeMiller
Diamond | Level 26

Do you want the final output as a report or table; or do you want the final output to be a SAS data set with the extra rows?

--
Paige Miller
Reeza
Super User

How are you planning to display your table? PROC REPORT/TABULATE/MEANS can do this automatically. 

And is it created from a summary procedure initially? If so, you can likely


@epi_user wrote:

I have a dataset that has many age categories by race and I am interested in combining all age categories in each race in each county to create a "total" variable for each county . 

 

thank you! 

 

I'd like the final data to look like this: 

 County Race Age _2020

x Asi 15-19 65
x Asi 20-24 34
x Asi 25-29 45
x Asi Total 144
y Asi 15-19 16
y Asi 20-24 9
y Asi 25-29 13
y Asi Total 38

 

the original data looks like this: 

County Race Age _2020
x Asi 15-19 65
x Asi 20-24 34
x Asi 25-29 45
y Asi 15-19 16
y Asi 20-24 9
y Asi 25-29 13


add in the total calculation to that step.

 

 

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

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
  • 1083 views
  • 0 likes
  • 3 in conversation