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

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 !

1 ACCEPTED SOLUTION

Accepted Solutions
ballardw
Super User

@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!!!!

 

 

View solution in original post

4 REPLIES 4
ballardw
Super User

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.

hawari
Calcite | Level 5

Hi Ballardw ,yes I tried using this : rowaxisopts=(type=log logots=(base=10)) ... but it didn't work .

ballardw
Super User

@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!!!!

 

 

hawari
Calcite | Level 5

thx @ballardw ! it works now

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
How to Concatenate Values

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.

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
  • 4 replies
  • 316 views
  • 1 like
  • 2 in conversation