BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
need_some_help
Calcite | Level 5

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!

1 ACCEPTED SOLUTION

Accepted Solutions
need_some_help
Calcite | Level 5

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

1 REPLY 1
need_some_help
Calcite | Level 5

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

sas-innovate-2024.png

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.

 

Register now!

SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

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
  • 1 reply
  • 825 views
  • 0 likes
  • 1 in conversation