Desktop productivity for business analysts and programmers

Groups order in grouped stacked bar chart.

Accepted Solution Solved
Reply
Contributor
Posts: 56
Accepted Solution

Groups order in grouped stacked bar chart.

Hi,

I use grouped&stacked bar chart for my data set. And I need groups in that bar chart to have certain order. When using the simplest bar chart you can do it with midpoints option. But I can't find the way to use it correct for grouped&stacked bar chart.

For example:

/*data*/

data sample;
length week agent type $12.;
do week='week1','week2','week3';
do agent='agent1','agent2','agent3','agent4';
do type='type1','type2';

num=ceil(ranuni(0)*10);
output;

end;
end;
end;
run;

/*gchart*/

%_eg_conditional_dropds(WORK.SORTTempTableSorted);
PROC SQL;
CREATE VIEW WORK.SORTTempTableSorted AS
  SELECT T.type, T.week, T.agent, T.num
FROM WORK.SAMPLE as T
;
QUIT;
Legend1
FRAME
;
Axis1
STYLE=1
WIDTH=1
MINOR=NONE


;
Axis2
STYLE=1
WIDTH=1


;


;
TITLE;
TITLE1 "title";
FOOTNOTE;
FOOTNOTE1 "footnote";
PROC GCHART DATA=WORK.SORTTempTableSorted
;
VBAR
  type
/
SUMVAR=num
SUBGROUP=agent
GROUP=week
CLIPREF
FRAME TYPE=SUM
LEGEND=LEGEND1
COUTLINE=BLACK
RAXIS=AXIS1
MAXIS=AXIS2
;

RUN; QUIT;
%_eg_conditional_dropds(WORK.SORTTempTableSorted);
TITLE; FOOTNOTE;

Is there any way to have groups in a special order: e.g. 'week2' 'week1' 'week3'?     (using      midpoints='week2' 'week1' 'week3'      gives incorrect result...)

Thank's in advance!


Accepted Solutions
Solution
‎09-14-2011 08:19 AM
Contributor
Posts: 56

Groups order in grouped stacked bar chart.

It's funny vut only after posting this message I found somethinf useful in documentation I've already read)):

there is rather simple way:

%_eg_conditional_dropds(WORK.SORTTempTableSorted);


PROC SQL;
CREATE VIEW WORK.SORTTempTableSorted AS
  SELECT T.type, T.week, T.agent, T.num
FROM WORK.SAMPLE as T
;
QUIT;
Legend1
FRAME
;
Axis1
STYLE=1
WIDTH=1
MINOR=NONE


;
Axis2
STYLE=1
WIDTH=1

;

/*!!!!!!!!!*/
Axis3
order=('week2' 'week1' 'week3') ;
/*!!!!!!!!!*/

;
TITLE;
TITLE1 "title";
FOOTNOTE;
FOOTNOTE1 "footnote";
PROC GCHART DATA=WORK.SORTTempTableSorted
;
VBAR
  type
/
SUMVAR=num
SUBGROUP=agent
GROUP=week
CLIPREF
FRAME TYPE=SUM
LEGEND=LEGEND1
COUTLINE=BLACK
RAXIS=AXIS1
MAXIS=AXIS2
/*!!!!!!!!!*/
GAXIS=AXIS3;
/*!!!!!!!!!*/
;

RUN; QUIT;
%_eg_conditional_dropds(WORK.SORTTempTableSorted);
TITLE; FOOTNOTE;

Merphy's law)))

View solution in original post


All Replies
Solution
‎09-14-2011 08:19 AM
Contributor
Posts: 56

Groups order in grouped stacked bar chart.

It's funny vut only after posting this message I found somethinf useful in documentation I've already read)):

there is rather simple way:

%_eg_conditional_dropds(WORK.SORTTempTableSorted);


PROC SQL;
CREATE VIEW WORK.SORTTempTableSorted AS
  SELECT T.type, T.week, T.agent, T.num
FROM WORK.SAMPLE as T
;
QUIT;
Legend1
FRAME
;
Axis1
STYLE=1
WIDTH=1
MINOR=NONE


;
Axis2
STYLE=1
WIDTH=1

;

/*!!!!!!!!!*/
Axis3
order=('week2' 'week1' 'week3') ;
/*!!!!!!!!!*/

;
TITLE;
TITLE1 "title";
FOOTNOTE;
FOOTNOTE1 "footnote";
PROC GCHART DATA=WORK.SORTTempTableSorted
;
VBAR
  type
/
SUMVAR=num
SUBGROUP=agent
GROUP=week
CLIPREF
FRAME TYPE=SUM
LEGEND=LEGEND1
COUTLINE=BLACK
RAXIS=AXIS1
MAXIS=AXIS2
/*!!!!!!!!!*/
GAXIS=AXIS3;
/*!!!!!!!!!*/
;

RUN; QUIT;
%_eg_conditional_dropds(WORK.SORTTempTableSorted);
TITLE; FOOTNOTE;

Merphy's law)))

☑ This topic is SOLVED.

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

Discussion stats
  • 1 reply
  • 231 views
  • 0 likes
  • 1 in conversation