Data visualization with SAS programming

Call to all Graph Experts --Please resolve this

Accepted Solution Solved
Reply
Contributor
Posts: 37
Accepted Solution

Call to all Graph Experts --Please resolve this

 

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;

 


Accepted Solutions
Solution
‎08-26-2016 08:20 PM
SAS Super FREQ
Posts: 890

Re: Call to all Graph Experts --Please resolve this

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;

View solution in original post

Attachment

All Replies
Grand Advisor
Posts: 17,428

Re: Call to all Graph Experts --Please resolve this

Sample data to replicate your code?

Contributor
Posts: 37

Re: Call to all Graph Experts --Please resolve this

Attached

Grand Advisor
Posts: 10,239

Re: Call to all Graph Experts --Please resolve this

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...

Contributor
Posts: 37

Re: Call to all Graph Experts --Please resolve this

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
;;;;

SAS Super FREQ
Posts: 3,416

Re: Call to all Graph Experts --Please resolve this

Please provide your version of SAS.

Contributor
Posts: 37

Re: Call to all Graph Experts --Please resolve this

SAS 9.2 M2

SAS Super FREQ
Posts: 890

Re: Call to all Graph Experts --Please resolve this

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

Contributor
Posts: 37

Re: Call to all Graph Experts --Please resolve this

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;

Contributor
Posts: 37

Re: Call to all Graph Experts --Please resolve this

Sorry it was 9.4M2. Typo 

Solution
‎08-26-2016 08:20 PM
SAS Super FREQ
Posts: 890

Re: Call to all Graph Experts --Please resolve this

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;

Attachment
Contributor
Posts: 37

Re: Call to all Graph Experts --Please resolve this

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

SAS Super FREQ
Posts: 890

Re: Call to all Graph Experts --Please resolve this

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

☑ This topic is SOLVED.

Need further help from the community? Please ask a new question.

Discussion stats
  • 12 replies
  • 519 views
  • 2 likes
  • 5 in conversation