Hello,
I am trying to graph data similar to the following data set "Employees":
| Age | Year |
|---|---|
| 19 | 2000 |
| 25 | 2000 |
| 18 | 2001 |
| 45 | 2000 |
| ... | ... |
| 38 | 2001 |
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.
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.
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.
It worked, thank you for the help.
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
Still thinking about your presentation idea? The submission deadline has been extended to Friday, Nov. 14, at 11:59 p.m. ET.
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.
Ready to level-up your skills? Choose your own adventure.