Data visualization with SAS programming

proc sgplot tickmarks negativ to postive with 0 on yaxis?

Accepted Solution Solved
Reply
Regular Contributor
Posts: 166
Accepted Solution

proc sgplot tickmarks negativ to postive with 0 on yaxis?

Hi All,

 

I trying to develop the scatter plot by using proc sgplot.

Min and max values are negative to positive , i wan to show 0 on in the y-axis.

 

proc sgplot data=have;

 scatter y=pct x=dur/group=col

yaxis values=(&min to &max by 10);

...

...

run;

 

for example min is -140 & max is 200

I want yaxis like below

     -140 -120 -100 -80 -60 -40 -20 0 20 40 60 80 100 120 140 160 180 200

 

Thanks

Sam


Accepted Solutions
Solution
‎03-07-2016 07:27 PM
Grand Advisor
Posts: 9,748

Re: proc sgplot tickmarks negativ to postive with 0 on yaxis?

[ Edited ]

You shown values of -130 -110 -90 -70 -50 -30 -10 10 30 50 70 90 110 130 150 170 190 are because you are using BY 20.

yaxis values = (-130 to -10 by 20 0 10 to 190 by 20) may work.

 

Simplier might be (-140 to 200 by 20) so 0 appears as a multiple of 20 added to -140.

 

 

View solution in original post


All Replies
Grand Advisor
Posts: 9,748

Re: proc sgplot tickmarks negativ to postive with 0 on yaxis?

You are missing a semicolon at the end of the Scatter statement.

 

If you are getting errors please post them.

If the results are just not showing all the values then it may be a result of the amount of space your default graph has available.

If something else, then post data in a data step and the complete proc code you have used.

Regular Contributor
Posts: 166

Re: proc sgplot tickmarks negativ to postive with 0 on yaxis?

Hi ,

 

Thank you for the response!!!

 

I am not getting the errors.  Missing semicolon is a typo.

i am using :

yaxis values=(&min to &max by 5);

 

My values on the plot is getting like this

 

-130 -110 -90 -70 -50 -30 -10 10 30 50 70 90 110 130 150 170 190

 

want:

 

-130 -110 -90 -70 -50 -30 -10 0 10 30 50 70 90 110 130 150 170 190 

 

Solution
‎03-07-2016 07:27 PM
Grand Advisor
Posts: 9,748

Re: proc sgplot tickmarks negativ to postive with 0 on yaxis?

[ Edited ]

You shown values of -130 -110 -90 -70 -50 -30 -10 10 30 50 70 90 110 130 150 170 190 are because you are using BY 20.

yaxis values = (-130 to -10 by 20 0 10 to 190 by 20) may work.

 

Simplier might be (-140 to 200 by 20) so 0 appears as a multiple of 20 added to -140.

 

 

Regular Contributor
Posts: 166

Re: proc sgplot tickmarks negativ to postive with 0 on yaxis?

Thank you so Much

 

work like a champ

 

Sam

Post a Question
Discussion Stats
  • 4 replies
  • 328 views
  • 0 likes
  • 2 in conversation