Data visualization with SAS programming

Ordering X-axis value in SAS EG Bar Chart

Accepted Solution Solved
Reply
Occasional Contributor
Posts: 8
Accepted Solution

Ordering X-axis value in SAS EG Bar Chart

 Untitled.png

I have been trying to order above bars in the following order

CHILD(<12)

YOUTH(12-17)

YOUNG ADULT(18-25)

ADULT(26-64)

SENIOR(65+)

I couldn't figure out a way to do it in EG. Could you please provide some suggestion. Thank you

 

sandesh

 


Accepted Solutions
Solution
‎09-10-2016 12:02 AM
SAS Super FREQ
Posts: 889

Re: Ordering X-axis value in SAS EG Bar Chart

The code being generated in EG for this graph is using GCHART. Your best option is probably to use the MIDPOINTS option and list out the midpoints in the order you want them. In that case, you do not have re-map your values to numbers.

 

vbar age_group / midpoints=("CHILD(<12)" "YOUTH(12-17)" ... )

 

Hope this helps!

Dan

View solution in original post


All Replies
Grand Advisor
Posts: 10,206

Re: Ordering X-axis value in SAS EG Bar Chart

Is the axis label an actual character variable or the result of formatting a numeric?

Occasional Contributor
Posts: 8

Re: Ordering X-axis value in SAS EG Bar Chart

It is a actual character variable.

SAS Super FREQ
Posts: 889

Re: Ordering X-axis value in SAS EG Bar Chart

Is your data already in that order?

Occasional Contributor
Posts: 8

Re: Ordering X-axis value in SAS EG Bar Chart

Yes, they are. I even created a flag as shown below and plotted the data. This time all the bars were in order as I wanted but then I got into an issue of mapping them back. I dont know how to map like 1 back to CHILD(<12). If I dont use the flag though SAS forced all the bar appear in alphabetical order. 

CHILD(<12)1
YOUTH (12-17)2
YOUNG ADULT (18-25)3
ADULT (26-64)4
SENIOR (65+)5

 

 

Solution
‎09-10-2016 12:02 AM
SAS Super FREQ
Posts: 889

Re: Ordering X-axis value in SAS EG Bar Chart

The code being generated in EG for this graph is using GCHART. Your best option is probably to use the MIDPOINTS option and list out the midpoints in the order you want them. In that case, you do not have re-map your values to numbers.

 

vbar age_group / midpoints=("CHILD(<12)" "YOUTH(12-17)" ... )

 

Hope this helps!

Dan

☑ This topic is SOLVED.

Need further help from the community? Please ask a new question.

Discussion stats
  • 5 replies
  • 301 views
  • 0 likes
  • 3 in conversation