Hello @Manj,
You can make the median line have a dotted line by using lineattrs=(pattern=34).
What do you mean by increase the length of the caps. Do you mean the width of the caps or the thickness, or do you want the caps to go higher/lower on the y-axis?
You can use the NOOUTLINE option to remove the outline of the bars. And then use another HIGHLOW statement with TYPE=LINE to draw the median, and then you can set the median attribute. You can also use the HIGHLOW statement to increase the width of the caps.
To change the median line pattern, use the MEDIANATTRS option:
medianattrs=(pattern=dash)
For the cap size, use the CAPSCALE option:
capscale=1.5 /*for example */
Hope this helps!
Dan
Ignore what I posted. I thought you were still using box plots.
Instead of using a HIGHLOW plot for the whiskers, use a SCATTER plot with Y error bars. Then, you can use CAPSCALE to control the size of the caps.
@DanH_sas and all those replied,
Thanks, as I got some kind of clue from each of your responses.
@DanH_sas Thanks , I tried ERRORCAPSCALE (as shown in the https://blogs.sas.com/content/graphicallyspeaking/files/2017/11/Cap_Scale.txt) ,but that is not working for me . I use SAS 9.4 version. Is it because of that?
I found a way to keep the median dashed line.
See below my output and code:
data aaa;
set stat;
IQR=(p75-p25) *1.5;
IQR_plus=p75+IQR;
iqr_neg=p25-iqr;
mchar='-';
mbigchar='------------------------------------'; /** to keep the median dashed line***/
cnsrtxt=put(cnsr,mace.);
run;
proc sgplot data=aaa nocycleattrs;
highlow x=cnsr high=p75 low=p25 / group=cnsrtxt type=bar
groupdisplay=cluster grouporder=ascending clusterwidth=0.7 barwidth=0.7 name='a';
scatter x=cnsr y=mean / group=cnsrtxt groupdisplay=cluster
grouporder=ascending clusterwidth=0.7 markerattrs=(size=9 symbol=circlefilled );
scatter x=cnsr y=p75 / yerrorupper=iqr_plus yerrorlower=p75 group=cnsrtxt groupdisplay=cluster
grouporder=ascending clusterwidth=0.7 markerchar=mchar markercharattrs=(size=1); ;
scatter x=cnsr y=p25 / yerrorupper=p25 yerrorlower=iqr_neg group=cnsrtxt groupdisplay=cluster
grouporder=ascending clusterwidth=0.7 markerchar=mchar markercharattrs=(size=1);
scatter x=cnsr y=median / yerrorupper=median yerrorlower=median noerrorcaps group=cnsrtxt groupdisplay=cluster
grouporder=ascending clusterwidth=0.7 markerchar=mbigchar markercharattrs=(size=9);
keylegend 'a' / location=outside position=bottom across=1 title="";
xaxis display=none;
yaxis label =" xxxxxxxxxxxxxxxxx";
run;
The CAPSCALE options were added in SAS 9.4m5. What version do you have?
i use SAS 9.4
Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!
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.
Ready to level-up your skills? Choose your own adventure.