BookmarkSubscribeRSS Feed
Leo9
Quartz | Level 8

 

I want to display "0" as a tick on y-axis. The y-axis in my plot is log axis.

The ticks I have currently are 1E1, 1E2, etc. I am using SAS 9.4M2.

Is there any way to display 0 tick on the y-axis ?

 

7 REPLIES 7
ballardw
Super User

You need to provide a bit more detail of the code generating the graph as there may be different options available depending on your approach or procedure used.

Rick_SAS
SAS Super FREQ

You can't display 0 on a log-scale axis because log(0) is undefined.

 

You can display 1E-6, which is 6 units to the left of 1.

You can display 1E-10, which is 10 units to the left of 1.

You can display 1E-16, which is 16 units to the left of 1 and is about the limit of many numerical computations.

 

Leo9
Quartz | Level 8

Thanks. 

Does format works on log axis in 9.4M2 ? 

Jay54
Meteorite | Level 14

First, let me say I agree with Rick that one should not display a '0' on  a log axis.  Having said that, if you really want to do that, you can use a format to display the lowest value as '0' as shown below.  Or, with SAS 9.40M3, you can use special Unicode values in your format to display the smallest value as "approximately" 0 🙂

 

LogZero.png

 

data log;
input x y;
datalines;
1 0.1
2 1
3 10
4 10000
5 10000000
;
run;

 

proc format;
  value logzero
    0.0001="(*ESC*){unicode '2248'x} 0"
    1='1'
    1000='1000'
    1000000='1000000'
;
run;

 

ods html close;
ods listing gpath='C:\Work\SASUser' image_dpi=200;
ods graphics / reset width=5in height=3in imagename='LogZero';
proc sgplot data=log;
  format y logzero.;
  scatter x=x y=y;
  yaxis type=log logbase=10 min=0.0001 grid
           values=(0.0001 1 1000 1000000) ;
run;

Leo9
Quartz | Level 8

Thank you all for all the answers. I ended up doing the log transformation first and then using linear scale.

I used format to display values I needed. 

Rick_SAS
SAS Super FREQ

Just to warn you, if you intend to show this graph to someone else, they might notice that it makes no sense.

Leo9
Quartz | Level 8

Thanks Rick. Not using log..it is linear. 

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 7 replies
  • 2770 views
  • 3 likes
  • 4 in conversation