BookmarkSubscribeRSS Feed
skyrocket
Calcite | Level 5

Hi,

I am using a Proc Gchart to generate a graph with status_buckets along the xaxis and their Statuses (Pending Delivered Returned) of the each bucket on Y axis:

This is the piece of code i am using to generate the graph.

proc gchart data = Prep_File_Final_1;

vbar status_bucket/noframe descending type=pct subgroup=Status legend=legend1 inside=pct

g100 group=status_bucket

nozero raxis=axis1 maxis=axis2 gaxis=axis3 ;

run;

quit;

As of now the graph plots Status_bucket values like this:

$0.01 - $0.24,      $0.25 - $0.49,      $0.50 - $0.99,       $1.00 - $4.99,       $10.00 - $24.99,      $100.00 - $499.99      $25.00 - $49.99,       $5.00 - $9.99,  $50.00 - $99.99,   $500.00 - Max

i would like to get the values plotted in this order on the x axis :

$0.01 - $0.24,      $0.25 - $0.49,      $0.50 - $0.99,       $1.00 - $4.99,      $5.00 - $9.99,      $10.00 - $24.99,       $25.00 - $49.99,      $50.00 - $99.99,      $100.00 - $499.99,      $500.00 - Max

Thanks,

2 REPLIES 2
ballardw
Super User

When you want things to appear in numeric order, use numbers. I'm betting you coded status bucket as a character variable with actual values of "$0.01 - $0.24". Which was likely a step that actually isn't needed.

If you have a prior dataset with a status numeric value you likely can use that variable by applying a numeric custom format as Gchart will use formatted values for display.

The format would look like assuming the variable is decimal, 0.01 = $.01, if actually cents then remove the decimals in the format:

proc format;

value bucket

0.01 - 0.24 = '$0.01 - $0.24'

0.25  - 0.49 = '$0.25 - $0.49'

<contine the hopefully obvious pattern>

500 - high = '$500.00 - Max'

;

run;

Or use numeric groups and format the group variable.

Then associate the format with your value variable in the proc gchart code:

format variable bucket.;

The above approach is VERY useful because you can create multiple bucket type formats and only change the format statement to see how different groups behave instead of creating multiple bucket variables.

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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
  • 1743 views
  • 1 like
  • 2 in conversation