BookmarkSubscribeRSS Feed
jdub
Calcite | Level 5

Hi,

I have a variable (agegrp) that is an age interval identifier.  Values of agegrp would look something like 14-18, 19-21, etc.  My second variable is a count of employment (emp) that corresponds to agegrp identifiers.  I am trying to create a histogram that is an age distribution of employment.  I'd like to graph an age distribution with each series the share of total employment x agegrp.  On the y-axis would be percent of total employment and the agegrp identifiers on the x-axis.  The code I have so far is:

proc gchart data=manu_agedist(where=(time="1995:1"));

vbar agegrp / dsicrete type=percent

                    sumvar=emp sum;

run;

This code yields counts of employment on the y-axis and agegrps on the x-axis.  Does anyone have advice on how to fix my code so I can graph an age distribution with each series the share of total employment x agegrp?

1 REPLY 1
DF
Fluorite | Level 6 DF
Fluorite | Level 6

Without seeing your source data I've made some assumptions about what it looks like, but the below should do what you need:

data manu_agedist;

format agegrp $10.;

format emp 8.;

infile datalines dsd;

input agegrp $ emp;

datalines;

18-25,500

26-29,250

30-36,333

37-44,123

45-54,999

55-64,40

65+,5

;

run;

proc gchart data=manu_agedist;

vbar agegrp / discrete type=percent freq=emp;

run;

proc tabulate data=manu_agedist;

class agegrp;

var emp;

table agegrp, colpctsum*emp;

run;

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

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
  • 1 reply
  • 1374 views
  • 0 likes
  • 2 in conversation