LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous messageNext messagePrevious in topicNext in topicPrevious by same authorNext by same authorPrevious page (January 2011, week 1)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Wed, 5 Jan 2011 22:26:08 -0800
Reply-To:     Jack Hamilton <jfh@STANFORDALUMNI.ORG>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         Jack Hamilton <jfh@STANFORDALUMNI.ORG>
Subject:      Re: PROC GCHART: Explicitly control the ordering of group
              variables
Comments: To: Matthew Pettis <matt.pettis@THOMSONREUTERS.COM>
In-Reply-To:  <201101060603.p05LJElR004955@wasabi.cc.uga.edu>
Content-Type: text/plain; charset=us-ascii

I haven't used GCHART in a long time, but will GAXIS with ORDER= do what you want?

On Jan 5, 2011, at 10:03 PM, Matthew Pettis wrote:

> Hi, > > I am trying to make a gchart in which I explictly control the order of the > group= option in the code. > > I have a solution, and I am wondering if there is a better way than how I > did it. > > My solution was to explicitly add a numeric order varialbe to my dataset > that represents the order in which I want the grouping values to display, > and then apply a format with the values that I want displayed back onto the > newly created order variable. This is in the code below. > > This to me seems sub-optimal, and seems like a request that would be so > common as to have some option in gchart that would aid me. I thought of > using 'midpoints', but I included that example in the code below and, if you > run it, you can see it does not do what I want. > > Any "yer doin' it wrong," reply, with a better solution, is heartily > welcomed. > > TIA, > Matt > > > > > > * > -------------------------------------------------------------------- > Code Section > -------------------------------------------------------------------- > ; > > data have; > infile datalines; > input X:$1. Y$1. Z order_val; > datalines; > A E 90 1 > A D 70 2 > A F 50 3 > A G 30 4 > A H 10 5 > B E 95 1 > B D 65 2 > B F 55 3 > B G 25 4 > B H 15 5 > ; > run; > > * This is close to what I want; > * It has the right grouping and subgrouping.; > * But I want to be able to control the order; > * In a general descending manner:; > goptions reset=all; > proc gchart data=have; > vbar X / > sumvar=Z > group=Y > subgroup=X > ; > run; > quit; > > > > > > * I do have a solution to the problem,; > * which is to do the following:; > proc format; > value morder > 1 = 'E' > 2 = 'D' > 3 = 'F' > 4 = 'G' > 5 = 'H' > ; > run; > > proc datasets; > modify have; > format order_val morder.; > run; > quit; > > goptions reset=all; > proc gchart data=have; > vbar X / > sumvar=Z > group=order_val > subgroup=X > ; > run; > quit; > > > > > > * I thought I could control the; > * order with something simple; > * like the following:; > * midpoints='E' 'D' 'F' 'G' 'H'; > * but you can run the code below; > * and see that it does not work out.; > * BAD/UNWANTED OUTPUT:; > goptions reset=all; > proc gchart data=have; > vbar X / > sumvar=Z > group=Y > subgroup=X > midpoints='E' 'D' 'F' 'G' 'H' > ; > run; > quit;


Back to: Top of message | Previous page | Main SAS-L page