Hi
I am trying to create a simple graph with age group and gender but somehow it is not working.
This is my code and the graph. I do not understand why it is spliting my age groups
all numeric but I formatted the age to be able to show in the graph - might be what is causing the issue, the original data is numeric with the actual age of each participant.
ID | Age | gender |
1 | Age 70-79 | 2 |
2 | Age 65-69 | 1 |
3 | Age 65-69 | 2 |
4 | Age 81-84 | 1 |
5 | Age 65-69 | 1 |
6 | Age 65-69 | 2 |
7 | Age 81-84 | 2 |
8 | Age 81-84 | 2 |
9 | Age 81-84 | 2 |
10 | Age 65-69 | 2 |
11 | Age 65-69 | 2 |
12 | Age 70-79 | 1 |
13 | Age 65-69 | 2 |
14 | Age 65-69 | 2 |
15 | Age 70-79 | 1 |
16 | Age 65-69 | 2 |
17 | Age 70-79 | 2 |
18 | Age 65-69 | 2 |
19 | Age 70-79 | 2 |
20 | Age 65-69 | 1 |
21 | Age 81-84 | 2 |
22 | Age 65-69 | 2 |
23 | Age 70-79 | 2 |
24 | Age 65-69 | 2 |
Thank you!!!
Try
axis2 label=('Age' j=r 'Group') order=(1 2 3) ;
That 1.5 and 2.5 tell me that your data is not actually using the age format that you displayed which would be using values more like 65 70 and 81.
I think you have observations with an age of 80, which is not covered in your format statement. Thus, the unformattted value is being displayed for that age.
PROC GCHART picks its own levels for the Y-axis, and I'm guessing it has picked levels that are 5 units apart. If you want your own levels to be used, as you did in AXIS1 (for the x-axis), use the ORDER option for AXIS2.
I figured it out. It was my variable formatting.
Now what I can't figure out is how to remove these tick mark on the Age axis. I do not need the 1.5 or 2.5. This is being generated in the code I shared and I cannot figure out how to change it. Thank you again.
Try
axis2 label=('Age' j=r 'Group') order=(1 2 3) ;
That 1.5 and 2.5 tell me that your data is not actually using the age format that you displayed which would be using values more like 65 70 and 81.
Thank you!
One last thing. How do I make all of these labels a little bigger on each of the axis?
Thank you!
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.