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
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;
|