BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
shaknon
Calcite | Level 5

Hello,

I am trying to graph data similar to the following data set "Employees":

AgeYear
192000
252000
182001
452000
......
382001

I used gchart to graph the data as follows:

proc gchart data = Employees;

     vbar Age / MIDPOINTS= 0 to 100 by 10 subgroup = Year ;

     run;

quit;

I want the chart to display the midpoints on the x-axis (10 age categories) and the frequency of each age category on the y-axis for each year (i.e. 2000 and 2001). I want the year subgroups to be displayed side by side for each age category. However, with this code I get the 2001 bars stacked on top of the 2000 bars for each age category. I looked online and I read many examples such as this example, but I am not sure why my code is not displaying the subgroup bars side by side as illustrated in the previous example.

Any help would be appreciated. Thanks.

1 ACCEPTED SOLUTION

Accepted Solutions
ballardw
Super User

I would try

vbar year/ group age;

format age chartage.;

Where chartage is a custom format that looks something like

Proc format;

value chartage

0-5 = ' 0 -5'

6-15 = ' 6-15'

16-25= '16-25'

(etc);

Notice that the example doesn't use MIDPOINTS and SUBGROUP is within GROUP.

View solution in original post

2 REPLIES 2
ballardw
Super User

I would try

vbar year/ group age;

format age chartage.;

Where chartage is a custom format that looks something like

Proc format;

value chartage

0-5 = ' 0 -5'

6-15 = ' 6-15'

16-25= '16-25'

(etc);

Notice that the example doesn't use MIDPOINTS and SUBGROUP is within GROUP.

shaknon
Calcite | Level 5

It worked, thank you for the help.

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!

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
  • 1048 views
  • 0 likes
  • 2 in conversation