Dear all,
I would like to change the labels of each bar but keeping same order of procedure.
Please find my code:
proc sgplot data=toto noborder;
styleattrs datacolors=(Firebrick big vpap deepskyblue ) ;
vbar patient / response=time /*stat=sum*/
group=procedure fil barwidth=0.2 seglabel seglabelattrs=(color=white size=12 ) /*datalabel*/
baselineattrs=(thickness=0 ) groupdisplay=stack
outlineattrs=(color=cx3f3f3f);
keylegend / position=right;
xaxis display=(nolabel noline noticks);
yaxis label='Hours' grid;
title 'Procedure times';
run;
Please find below the graph inside attachments.
I would like to replace:
'01:Induction' by 'Induction'
'02:Incis_CPB' by 'Incision to CPB'
'03:CPBDurati' by 'CPB duration'
'04:skin_clos' by CPB stop to skin closure
Thank all for your support,
Its a good idea to indicate "what doesn't work" in future. I guess its because you didn't apply the format:
proc format lib=work; value $procedure '01:Induction' = 'Induction' '02:Incis_CPB' = 'Incision to CPB' '03:CPBDurati' = 'Incision to CPB' '04:skin_clos' = 'CPB stop to skin closure'; run; title 'Procedure times'; proc sgplot data=toto noborder; styleattrs datacolors=(Firebrick big vpap deepskyblue ) ; vbar patient / response=time group=procedure barwidth=0.2 seglabel seglabelattrs=(color=white size=10) baselineattrs=(thickness=0 ) nooutline outlineattrs=(color=cx3f3f3f); format procedure $procedure.; keylegend / position=right; xaxis display=(nolabel noline noticks); yaxis label='Hours' grid; run;
Note the format line.
Dear all,
I would like to change the labels of each bar but keeping same order of procedure.
Please find my code:
proc sgplot data=toto noborder;
styleattrs datacolors=(Firebrick big vpap deepskyblue ) ;
vbar patient / response=time /*stat=sum*/
group=procedure fil barwidth=0.2 seglabel seglabelattrs=(color=white size=12 ) /*datalabel*/
baselineattrs=(thickness=0 ) groupdisplay=stack
outlineattrs=(color=cx3f3f3f);
keylegend / position=right;
xaxis display=(nolabel noline noticks);
yaxis label='Hours' grid;
title 'Procedure times';
run;
Please find below the graph inside attachments.
I would like to replace:
'01:Induction' by 'Induction'
'02:Incis_CPB' by 'Incision to CPB'
'03:CPBDurati' by 'CPB duration'
'04:skin_clos' by CPB stop to skin closure
Thank all for your support,
The way to do this is to make your categories numeric, i.e. 1 for the first, 2 for the second etc. and apply a format to them with the full text. This way the data orders correctly per the numeric, and displays the full formatted value.
I do not used very often proc format.
I try this code but that does not work:
proc format lib=work;
value $ procedure '01:Induction' = 'Induction'
'02:Incis_CPB' = 'Incision to CPB'
'03:CPBDurati' = 'Incision to CPB'
'04:skin_clos' = 'CPB stop to skin closure';
run;
proc sgplot data=toto noborder;
styleattrs datacolors=(Firebrick big vpap deepskyblue ) ;
vbar patient / response=time /*stat=sum*/
group=procedure barwidth=0.2 seglabel seglabelattrs=(color=white size=10) /*datalabel*/
baselineattrs=(thickness=0 ) nooutline /*groupdisplay=stack*/
outlineattrs=(color=cx3f3f3f);
Format procedure;
keylegend / position=right;
xaxis display=(nolabel noline noticks);
yaxis label='Hours' grid;
title 'Procedure times';
run;
Its a good idea to indicate "what doesn't work" in future. I guess its because you didn't apply the format:
proc format lib=work; value $procedure '01:Induction' = 'Induction' '02:Incis_CPB' = 'Incision to CPB' '03:CPBDurati' = 'Incision to CPB' '04:skin_clos' = 'CPB stop to skin closure'; run; title 'Procedure times'; proc sgplot data=toto noborder; styleattrs datacolors=(Firebrick big vpap deepskyblue ) ; vbar patient / response=time group=procedure barwidth=0.2 seglabel seglabelattrs=(color=white size=10) baselineattrs=(thickness=0 ) nooutline outlineattrs=(color=cx3f3f3f); format procedure $procedure.; keylegend / position=right; xaxis display=(nolabel noline noticks); yaxis label='Hours' grid; run;
Note the format line.
Thank you
Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.
If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website.
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.