BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Leo9
Quartz | Level 8

 

OK, this is going to be an interesting and challenging problem. Need help of all the experts.

 

Issue : I am trying to plots some low to very high values (1 - 1000000000000)  on y-axis. X-axis is visit.

I am using Log scale for y-axis. I have following ticks on y-axis - 1, 1E1, 1E2, IE3...1E12.

I want to show values for tick 1E4 close to 1. Basically, I want minium gap between 1 and 1E4. How can this be

achieved ? 

 

I tried to use broken axis but it doesn't work with log scale. I would like to use log scale. 

Please provide any suggestion 

 

Here is the sample code :

 

proc sgplot data = lbs ;
series x = weeks y = lbstresn / group = subjid groupms=subjid markers markerattrs=(size =4);
yaxis label = &lbl type = log logstyle = logexpand logvtype = exponent display = all min = &min max = &max;
xaxis values= (-1 to 36 by 1 ) label = " Weeks" display = all ;
keylegend / valueattrs = (size=6) title = 'Subjects' ;
run;

 

1 ACCEPTED SOLUTION

Accepted Solutions
DanH_sas
SAS Super FREQ

See the attached picture to see if this is the desired effect. I created it with your sample data and a slight modification of your code:

 

data test2;
set test;
lbstresn2 = log10(lbstresn);
run;

proc sgplot data = test2 ;
series x = weeks y = lbstresn2 / group = subjid groupms=subjid markers markerattrs=(size =4);
yaxis label = "Y axis label" type = linear ranges = (0-0.3 3.8-8) values=(0 to 8 by 0.1) display = all;
xaxis values= (-3 to 36 by 1 ) label = "Weeks" display = all ;
keylegend / valueattrs = (size=6) title = 'Subjects' ;
run;


BrokenAxis.png

View solution in original post

12 REPLIES 12
Reeza
Super User

Sample data to replicate your code?

Leo9
Quartz | Level 8

Attached

ballardw
Super User

Many users here don't want to download Excel files because of virus potential, others have such things blocked by security software. Also if you give us Excel we have to create a SAS data set and due to the non-existent constraints on Excel data cells the result we end up with may not have variables of the same type (numeric or character) and even values.

 

You can generate datastep code that can be pasted as text here using the information from this link https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-dat...

Leo9
Quartz | Level 8

Here is the sample data

 

data WORK.TEST;
infile datalines dsd truncover;
input LBTESTCD:$8. LBSTRESN:32. SUBJID:$9. WEEKS:32.;
datalines4;
SHDC,333032.03,102,0.1428571429
SHDC,290878.55,102,0.4285714286
SHDC,319447.4,102,1
SHDC,486860.71,102,2
SHDC,134068.56,102,3
SHDC,90190.05,102,4
SHDC,12000,102,6.1428571429
SHDC,12000,102,8
SHDC,12000,102,9
SHDC,,102,11.142857143
SHDC,,021,0.1428571429
SHDC,,021,0.4285714286
SHDC,,021,1.1428571429
SHDC,4395487.68,021,2
SHDC,7791809.28,021,3
SHDC,312460.46,021,4.1428571429
SHDC,52215.81,021,5
SHDC,12000,021,6
SHDC,12000,021,7
SHDC,12000,021,8
SHDC,12000,021,9
SHDC,12000,021,10
SHDC,34323.01,021,11
SHDC,12000,021,12
SHDC,12000,021,13
SHDC,12000,021,14.142857143
SHDC,12000,021,16
SHDC,1,022,-2.714285714
SHDC,75846.22,022,0.1428571429
SHDC,594414.43,022,0.5714285714
SHDC,350789.16,022,1
SHDC,434236.45,022,2
SHDC,220518.29,022,3
SHDC,37704.41,022,4.1428571429
SHDC,12000,022,5.1428571429
SHDC,12000,022,6
SHDC,12000,022,7
SHDC,12000,022,8
SHDC,1,022,9
SHDC,1,001,-1
SHDC,12000,001,0.1428571429
SHDC,74771.36,001,0.4285714286
SHDC,60308.3,001,1
SHDC,40144.87,001,2
SHDC,12000,001,4
SHDC,12000,001,5
SHDC,12000,001,6
SHDC,12000,001,7
SHDC,12000,001,8
SHDC,1,001,9
SHDC,1,001,10
SHDC,1,001,11
SHDC,1,001,12
SHDC,,001,13.142857143
SHDC,,001,14
SHDC,,001,15
SHDC,,001,28.285714286
SHDC,1,002,-1
SHDC,12000,002,0.1428571429
SHDC,12000,002,0.4285714286
SHDC,12000,002,1.2857142857
SHDC,12000,002,2.4285714286
SHDC,12000,002,3
SHDC,12000,002,4
SHDC,12000,002,5
SHDC,,002,6.1428571429
SHDC,,002,7
SHDC,1,002,8
SHDC,1,002,9
SHDC,12000,002,10
SHDC,1,002,11
SHDC,1,002,12
SHDC,1,002,13
SHDC,1,002,14
SHDC,1,002,15
SHDC,,002,16
SHDC,,002,20
SHDC,1,003,-1.142857143
SHDC,238238.52,003,0.1428571429
SHDC,426241.73,003,0.4285714286
SHDC,973322.23,003,1.2857142857
SHDC,268264.28,003,1.8571428571
SHDC,175213.31,003,2.8571428571
SHDC,29571.7,003,4
SHDC,12000,003,4.8571428571
SHDC,12000,003,5.8571428571
SHDC,12000,003,6.8571428571
SHDC,12000,003,7.8571428571
SHDC,1,123,-1
SHDC,7052629.92,123,0.1428571429
SHDC,50180642.4,123,0.4285714286
SHDC,16152353.28,123,1
SHDC,6006247.44,123,2
SHDC,4360246.56,123,3.1428571429
SHDC,431407.26,123,4
SHDC,57950.34,123,5
SHDC,30263.48,123,6
SHDC,12000,123,7
SHDC,1,124,-2
SHDC,2951737.13,124,1
SHDC,2206464.96,124,2
SHDC,280740.86,082,0.1428571429
SHDC,5193730.08,082,1
SHDC,17723615.04,082,2
SHDC,651633.96,082,4
SHDC,12000,082,6
SHDC,12000,082,7
SHDC,12000,082,8
;;;;

Rick_SAS
SAS Super FREQ

Please provide your version of SAS.

Leo9
Quartz | Level 8

SAS 9.2 M2

DanH_sas
SAS Super FREQ

What I would normally suggest in a situation like that would be to compute the log value into a separate column and use that column with a linear axis. That way, you can create a broken axis. However, if you are using SAS 9.2m2, then we did not have broken axis support (via the RANGES option) in SGPLOT. If you tried the RANGES option without a syntax error, did you mean SAS 9.4m2?

 

Thanks!
Dan

Leo9
Quartz | Level 8

Sorry I meant 9.4M2. Thanks for catching that.

 

I did try the solution you suggested but it is not working either.

What I did is did log transformation of the lab values first and then

use it with linear scale with range option. Interestingly y-axis is not

even getting broke now. Not sure why. 

 

proc sgplot data = lbs ;
series x = weeks y = lbstresn2 / group = subjid groupms=subjid markers markerattrs=(size =4);
yaxis label = &lbl type = linear /*min = &min max = &max*/ranges = (0-0.3 3.8-max) values = (0 to 18 by 0.1)  display = all;
xaxis values= (-3 to 36 by 1 ) label = "Weeks" display = all ;
keylegend / valueattrs = (size=6) title = 'Subjects' ;
run;

Leo9
Quartz | Level 8

Sorry it was 9.4M2. Typo 

DanH_sas
SAS Super FREQ

See the attached picture to see if this is the desired effect. I created it with your sample data and a slight modification of your code:

 

data test2;
set test;
lbstresn2 = log10(lbstresn);
run;

proc sgplot data = test2 ;
series x = weeks y = lbstresn2 / group = subjid groupms=subjid markers markerattrs=(size =4);
yaxis label = "Y axis label" type = linear ranges = (0-0.3 3.8-8) values=(0 to 8 by 0.1) display = all;
xaxis values= (-3 to 36 by 1 ) label = "Weeks" display = all ;
keylegend / valueattrs = (size=6) title = 'Subjects' ;
run;


BrokenAxis.png
Leo9
Quartz | Level 8

Yes this is what I wanted. Interestingly when I used the same range, it wasn't breaking Y-axis.

What did you modify ? Thanks again

DanH_sas
SAS Super FREQ

I changed the numeric range of the VALUES option, and I changed "max" in the RANGES option to be a literal value that enclosed the data range. I did the latter due to a log message about a magnitude issue with the RANGES option. The option was ignored because of it, which might be why the axis break did not work for you.

 

Thanks!
Dan

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
  • 12 replies
  • 2570 views
  • 2 likes
  • 5 in conversation