BookmarkSubscribeRSS Feed
jcochrane424
Calcite | Level 5

Hello everyone, so I'm working with a labor force population data set in SAS 9.4 that is broken up by industry, year, and age group, as you can see in the pic below. The current setup of the age groups that I'm dealing with is 25-34, 35-44, 45-54, 55-64, and 65 years over. What I'm trying to do is combine the age groups 25-34 and 35-44 into 25-44 and then 45-54 and 55-64 into one age group that's 45-64 for every industry and every year. FYI the data ranges from 2000-2013. In doing this I'm also trying to add the Labor_Force_Pop data point for the two age groups I'm combining, so I have one age group and one Labor_Force_Pop that has added the two previous numbers. Hopefully someone can help!!              labor force data.png

2 REPLIES 2
ChrisNZ
Tourmaline | Level 20

Just create a format:

proc format;
  value ages '25' - '44' = '25-44'
             '45' - '64' = '45-64';

and apply this format to the variable for your computations.

Reeza
Super User

Use PROC MEANS + FORMAT. 

 

@ChrisNZ has posted the required format. Here's an example of how to use it to aggregate your data. 

Although date are months, they're aggregated to years because of the year format applied.

 

/*Note that if you apply formats to your date they get grouped according to the format, so having a SAS date is advantageous.
Here's a quick example that shows the calculating of yearly statistics from a data set.*/

proc means data=sashelp.stocks N NMISS min max mean median STACKODS;
class date;
format date year4.;
var open high low;
output out=want n= mean= sum= median= mean= / autoname autolabel;
ods output summary = want2;
run;

@jcochrane424 wrote:

Hello everyone, so I'm working with a labor force population data set in SAS 9.4 that is broken up by industry, year, and age group, as you can see in the pic below. The current setup of the age groups that I'm dealing with is 25-34, 35-44, 45-54, 55-64, and 65 years over. What I'm trying to do is combine the age groups 25-34 and 35-44 into 25-44 and then 45-54 and 55-64 into one age group that's 45-64 for every industry and every year. FYI the data ranges from 2000-2013. In doing this I'm also trying to add the Labor_Force_Pop data point for the two age groups I'm combining, so I have one age group and one Labor_Force_Pop that has added the two previous numbers. Hopefully someone can help!!              labor force data.png


 

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

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