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:
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 |
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?
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.
Available on demand!
Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.
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.