I am using SGplot (SAS v9.2) for a plot with two log axes (log cmax versus log dose). Now I want to show all specific dose groups in het plot and not the automatic markers/ticks that SAS presents (50 100 150 200 250 300 350). For linear axes I use the the values option but for log axes this had no effect. Are there other options to define these values?
current code:
proc sgplot data = ds noautolegend;
scatter x=dose y=cmax;
xaxis label="Dose (mg)" type=log min=30 max=360 VALUES=(30 60 150 240 360);
yaxis label="Cmax (µg/mL)" type=log min=1 max=1000 ;
refline 1/axis=x ;
run;
You are right. There is no way to set custom tick values on a log axis. This is because of some options like LOGSTYLE that expect the tick values to be in multiples of certain magnitudes. With SAS 9.3, there may be a workaround but with SAS 9.2 I can't think of anything at this time. I suggest you call this in to Tech Support for addition in future releases.
If there's not a convenient way to do this in sgplot, perhaps you could use good-old gplot?
I'm not real good with log axes, but I've downloaded one of tech support's gplot log-axis examples, and made a simple modification to add dotted reference lines at certain points along the axis (different from the log tickmarks), and then adding text labels for the reflines. (Gplots pretty flexible, and this is just the first/easiest way that came to mind - there are probably some other ways...)
Here's the code:
goptions reset=all border cback=white gunit=pct htitle=3;
/* Create the data set CONCENTR */
data concentr;
input PH CONC;
datalines;
1 1E-1
2 1E-2
3 1E-3
4 1E-4
5 1E-5
6 1E-6
7 1E-7
8 1E-8
9 1E-9
10 1E-10
11 1E-11
12 1E-12
13 1E-13
14 1E-14
;
run;
/* Define the title */
title1 h=4 'Relationship of pH to H'
move=(-0,-2) h=2.8 '3'
move=(+0,+2) h=4 'O'
move=(+0,+2) h=2.8 '+'
move=(-0,-2) h=4 ' Concentration';
/* Define symbol characteristics */
symbol1 interpol=join color=black;
/* Define horizontal axis characteristics */
axis1 label=(h=4 'Scale of pH Values'
justify=left color=red h=4 'More acid'
justify=right color=blue 'More alkaline')
minor=none;
/* Define vertical axis characteristics */
axis2 logbase=10
logstyle=expand
color=black
reflabel=("first" "second")
label=(angle=90 h=4 color=black 'Concentration (Moles/Liter)' )
value=(tick=1 '10' height=2 '-14'
tick=2 '10' height=2 '-13'
tick=3 '10' height=2 '-12'
tick=4 '10' height=2 '-11'
tick=5 '10' height=2 '-10'
tick=6 '10' height=2 '-9'
tick=7 '10' height=2 '-8'
tick=8 '10' height=2 '-7'
tick=9 '10' height=2 '-6'
tick=10 '10' height=2 '-5'
tick=11 '10' height=2 '-4'
tick=12 '10' height=2 '-3'
tick=13 '10' height=2 '-2'
tick=14 '10' height=2 '-1')
major=(h=.8);
/* Generate plot and assign AXIS definitions */
proc gplot data= concentr;
plot conc*ph /
vref= 1.2E-4 1.6E-9
cvref=green lvref=33
haxis=axis1 vaxis=axis2;
run;
quit;
I would use the DATA step to define new variables logDose = log(dose) and logCMax=log(CMax) (or use LOG10(), if you prefer).
Then use SGPLOT with the new variables. You can specify whatever axes you want by using the VALUES option as in your example.
Rick
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.