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.

 

 

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 2 replies
  • 499 views
  • 0 likes
  • 3 in conversation