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
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.
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:
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
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.
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 !
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;
Thank you so much Rick!
You are the best! I applied your advice!
Thank you in advance again.
You made my day!
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
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...)
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!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.