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

Hi there!

I worked so hard to learn about SAS alone, but now I'm facing some... problems. So I need some help.

Actually I got so many questions, but I'll keep trying looking for the answer by myself.

But this one... I thought it would be easy to find the answer. But I couldn't.

 

Here's the thing.

 

I'd like to set the scale of the graph with the particular number. The goal is clear, and I attached the photo of goal.

Like the photo, I need certain numbers in the scale while the visual gap of the scale is equal.

 

And I made the graph with sgplot. So if you can help me the code in sgplot it would be great. (But any helping code would be appreciated!)

 

Thank you in advance

 

11.PNG

1 ACCEPTED SOLUTION

Accepted Solutions
Rick_SAS
SAS Super FREQ

Welcome to the SAS Communities. We were all beginners once, and we all make mistakes, so don't worry about it. Hopefully, the experts will offer gentle advice.

 

From your picture, it looks like you want a logarithmic scale on the Y axis. Use a YAXIS statement and specify TYPE=LOG to get a logarithmic axis. Specify LOGSTYLE=LOGEXPAND to show the numbers associated with each tick mark.  The following example should help you get started:

 

data Have;
do x = 1 to 5 by 0.1;
   y = 10**x;
   output;
end;
run;

proc sgplot data=Have;
series x=x y=y;
yaxis type=log logstyle=logexpand;
run;

Remember that if someone answers your question, you can mark the response as "Answered" so that others know you have accepted an answer and do not require further help.

View solution in original post

9 REPLIES 9
RW9
Diamond | Level 26 RW9
Diamond | Level 26

Please do not attach files zipped up, there is no way I am downloading files to my machine.  You can embed images in your post, look at the buttons above the post area.  Second, you need to at least show the code, post it as test using the code window - its the {i} above post area.  Its also useful (though maybe not in this case) to provide test data so that we can create something to run with - SAS is a data based language.  I will move you post to the relevant forum.

In terms of your question, supply an xaxis or yaxis statement like:

xaxis values=(0 1 2 3 4);

In your sgplot (note values should be the ones you want to see).

This link is vital for any graph programmers, has examples for everything:

https://blogs.sas.com/content/graphicallyspeaking/

MonoLight
Obsidian | Level 7

Thank you. And my bad.

I attached the photo!

But it will take some time to add code since it is working with sgplot (it take about 40 min since it should draw over 30,000 series in a chart...) I'll add the code later!

 

Thank you for the advice again.

It's my first time so... there are so many mistakes

Rick_SAS
SAS Super FREQ

Welcome to the SAS Communities. We were all beginners once, and we all make mistakes, so don't worry about it. Hopefully, the experts will offer gentle advice.

 

From your picture, it looks like you want a logarithmic scale on the Y axis. Use a YAXIS statement and specify TYPE=LOG to get a logarithmic axis. Specify LOGSTYLE=LOGEXPAND to show the numbers associated with each tick mark.  The following example should help you get started:

 

data Have;
do x = 1 to 5 by 0.1;
   y = 10**x;
   output;
end;
run;

proc sgplot data=Have;
series x=x y=y;
yaxis type=log logstyle=logexpand;
run;

Remember that if someone answers your question, you can mark the response as "Answered" so that others know you have accepted an answer and do not require further help.

MonoLight
Obsidian | Level 7

Thank you for understanding and help!

I'm really glad someone can help me. I saw logarithm before, but I thought it only show the scale of 10, 100, 1000 or something.

 

Is it possible to set 500 or other numbers as well?

 

Thank you for the answer again !

Rick_SAS
SAS Super FREQ

Yes, you can specify custom ticks, but on a logarithmic scale they won't be evenly spaced.

 

proc sgplot data=Have;
series x=x y=y;
yaxis type=log logstyle=logexpand 
      values=(100 500 1000 5000 10000 50000 100000);
run;
MonoLight
Obsidian | Level 7

Thank you so much Rick!

You are the best! I applied your advice!

 

 

 Thank you in advance again.

 

 

You made my day!

akhilvijayan382
Fluorite | Level 6

Thank you Rick,

 

I have tried the same but the scales in output presented are not as expected, please see the code below that I have used,

yaxis values=(0 10 100 1000 10000 100000 1000000 10000000) type=log logstyle=logexpand ;

 

Thanks in Advance,

Akhil

Rick_SAS
SAS Super FREQ

Log(0) is not defined, so you can't use 0 as a tick value on a log axis. Try

yaxis values=(1 10 100...)

akhilvijayan382
Fluorite | Level 6
Thank you

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!
Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 9 replies
  • 12273 views
  • 9 likes
  • 4 in conversation