DATA Step, Macro, Functions and more

trendline, Average Line or target line

Accepted Solution Solved
Reply
Occasional Contributor
Posts: 8
Accepted Solution

trendline, Average Line or target line

Hi All,

 

I'm having problems with the SGPLOT refline option  I have provided an example .  Please see attached


Accepted Solutions
Solution
2 weeks ago
Valued Guide
Posts: 559

Re: trendline, Average Line or target line

[ Edited ]

You can define the start and end values for axis in XAXIS, YAXIS values. 

 

something like: YAXIS values=(&min to &max by 0.1)

 

You can get the max and min values from the dataset using proc sql INTO;

 

proc sql;

select max(var1),Min(var2) into: max,:min

from have;

quit;

 

If you want the yaxis to extend then add values to max like: YAXIS values=(&min to &max+2 by 0.1)

 

Check this example how to increase the yaxis lines:

proc sql;
select max(weight)+50,min(weight) into: max,:min
from sashelp.class;
quit;
options symbolgen;
proc sgplot data=sashelp.class;
  scatter x=height y=weight / group=sex;
  yaxis values=(&min to &max by 20);
run;

If you still don't get then please provide your sample data in the form of data step. Someone can sure help you if you clearly provide your requirement. 

https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-dat...

Thanks,
Suryakiran

View solution in original post


All Replies
Solution
2 weeks ago
Valued Guide
Posts: 559

Re: trendline, Average Line or target line

[ Edited ]

You can define the start and end values for axis in XAXIS, YAXIS values. 

 

something like: YAXIS values=(&min to &max by 0.1)

 

You can get the max and min values from the dataset using proc sql INTO;

 

proc sql;

select max(var1),Min(var2) into: max,:min

from have;

quit;

 

If you want the yaxis to extend then add values to max like: YAXIS values=(&min to &max+2 by 0.1)

 

Check this example how to increase the yaxis lines:

proc sql;
select max(weight)+50,min(weight) into: max,:min
from sashelp.class;
quit;
options symbolgen;
proc sgplot data=sashelp.class;
  scatter x=height y=weight / group=sex;
  yaxis values=(&min to &max by 20);
run;

If you still don't get then please provide your sample data in the form of data step. Someone can sure help you if you clearly provide your requirement. 

https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-dat...

Thanks,
Suryakiran
☑ This topic is solved.

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

Discussion stats
  • 1 reply
  • 79 views
  • 0 likes
  • 2 in conversation