Hi , Please, doe you have an idea about how to show Y axis in base 10 log scale, in the code below ?
proc sort data=sashelp.class out=class;
by sex;
run;
proc means data=class nway mean clm noprint;
by sex;
class age;
var height;
output out=new mean= lclm= uclm= / autoname;
run;
proc template;
define statgraph barchart;
begingraph;
entrytitle 'Bar Chart with Error Bars';
layout gridded / border=false;
layout datalattice columnvar=sex / headerlabeldisplay=value cellwidthmin=50
columnheaders=bottom border=false columndatarange=union
columnaxisopts=(display=(line tickvalues))
rowaxisopts=(offsetmin=0 label='Mean Height' griddisplay=on);
layout prototype / walldisplay=(fill);
barchart x=age y=height_mean / group=sex barlabel=true
name='bar' outlineattrs=(color=black);
scatterplot x=age y=height_mean / group=sex yerrorlower=height_lclm
yerrorupper=height_uclm
markerattrs=(size=0) name='scatter'
errorbarattrs=(thickness=2) datatransparency=0.6;
endlayout;
endlayout;
endlayout;
endgraph;
end;
run;
proc sgrender data=new template=barchart;
run;
I tried this : rowaxisopts=(type=log logots=(base=10)) but it didn't work .
Thanks in advance for your help !
@hawari wrote:
Hi Ballardw ,yes I tried using this : rowaxisopts=(type=log logots=(base=10)) ... but it didn't work .
Just to clarify, you actually used
rowaxisopts=(type=log logopts=(base=10))
Did you see notes like this in the LOG:
NOTE: The log axis cannot support zero or negative values for the axis from plot data or due to default or assigned BASELINEINTERCEPT value. The axis type will be changed to LINEAR. NOTE: The log axis cannot support zero or negative values for the axis from plot data or due to default or assigned BASELINEINTERCEPT value. The axis type will be changed to LINEAR.
BAR Charts default to starting at 0. LOG Axis cannot use 0.
Try changing the BARCHART to
barchart x=age y=height_mean / group=sex barlabel=true groupdisplay=cluster name='bar' outlineattrs=(color=black) baselineintercept=1;
The default for groupdisplay is STACK, which disables the BASELINEINTERCEPT which allows not showing the 0 value. So change the Groupdisplay to CLUSTER even though your data, at least with this example, won't look any different and add the BASELINEINTERCEPT. You could use a smaller value but NOT ZERO!!!!
Start by adding a TYPE=LOG so SAS knows that you want a LOG based axis.
Then use LOGOPTS=(Base=10) to indicate the option(s) to apply.
Hi Ballardw ,yes I tried using this : rowaxisopts=(type=log logots=(base=10)) ... but it didn't work .
@hawari wrote:
Hi Ballardw ,yes I tried using this : rowaxisopts=(type=log logots=(base=10)) ... but it didn't work .
Just to clarify, you actually used
rowaxisopts=(type=log logopts=(base=10))
Did you see notes like this in the LOG:
NOTE: The log axis cannot support zero or negative values for the axis from plot data or due to default or assigned BASELINEINTERCEPT value. The axis type will be changed to LINEAR. NOTE: The log axis cannot support zero or negative values for the axis from plot data or due to default or assigned BASELINEINTERCEPT value. The axis type will be changed to LINEAR.
BAR Charts default to starting at 0. LOG Axis cannot use 0.
Try changing the BARCHART to
barchart x=age y=height_mean / group=sex barlabel=true groupdisplay=cluster name='bar' outlineattrs=(color=black) baselineintercept=1;
The default for groupdisplay is STACK, which disables the BASELINEINTERCEPT which allows not showing the 0 value. So change the Groupdisplay to CLUSTER even though your data, at least with this example, won't look any different and add the BASELINEINTERCEPT. You could use a smaller value but NOT ZERO!!!!
thx @ballardw ! it works now
Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.
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.