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


 

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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
  • 235 views
  • 0 likes
  • 3 in conversation