I'm generating a simple vbar chart with the Y axis being counts, and x axis being ranges that I created as text (i.e "0 to 5%", "5.01 to 10%" etc).
When I plot the chart, my X axis is out of order. it'll go "0 to 5%", "10 to 15%", "5 to 10%". How do I set the order in this scenario where the x axis is text?
Proc sgplot data=gridwork.data;
vbar dist/ response=counts;
xaxis label=distribution;
yaxis label='counts;
run;
quit;
Easiest method is to not use characters as your X axis. Instead use numeric values and then use a format to have them displayed for presentation.
Because its a categorical variable you can also use the VALUES = option on the XAXIS statement to have the order you want.
proc sgplot data=sashelp.cars;
xaxis values=("GMC" "Honda" "Hyundai")
offsetmin=0.2 offsetmax=0.2;
scatter x=make y=mpg_city;
run;
PS. please take some time to go through your historical posts and mark them as answered/solved with the correct response tagged.
@mrdlau wrote:
I'm generating a simple vbar chart with the Y axis being counts, and x axis being ranges that I created as text (i.e "0 to 5%", "5.01 to 10%" etc).
When I plot the chart, my X axis is out of order. it'll go "0 to 5%", "10 to 15%", "5 to 10%". How do I set the order in this scenario where the x axis is text?
Proc sgplot data=gridwork.data; vbar dist/ response=counts; xaxis label=distribution; yaxis label='counts; run; quit;
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.
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.