turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

Find a Community

- Home
- /
- SAS Programming
- /
- SAS/GRAPH and ODS Graphics
- /
- adding an equation to draw to a plot statement

Topic Options

- RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page

- Mark as New
- Bookmark
- Subscribe
- RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

11-26-2009 11:32 AM

Hello dears sas users

My problem is the following:

imagine that i have a plot to draw and i want also to add in the graphic an equation

like Y=X

is it possible ?

because for the moment, i work like that but if there is a shorter and easier way to do it, it would be nice

here is my code:

data class;

set sashelp.class end=fin;

x_1= _n_ * 3;

y_1= _n_ * 3;

weight=weight/2;

if _n_ = 1 then do;; x_1=0; y_1=0; end;

if fin then do; x_1=80; y_1=80; end;

run;

goptions reset=all;

title 'is there a shorter way ???';

symbol1 color=red

interpol=join

value=dot

height=3;

symbol2 value=none

color=black

interpol=join

height=2;

axis1 order=(0 to 100 by 20) offset=(0,0)

label=none

major=(height=2) minor=(height=1)

width=3;

axis2 order=(0 to 100 by 20) offset=(0,0)

label=none

major=(height=2) minor=(height=1)

width=3;

proc gplot data=class;

plot height*weight x_1*y_1 / overlay haxis=axis1 vaxis=axis2 ;

run;

quit;

may be is a dream but it would be very nice if the following code exists;

proc gplot data=sashelp.class;

plot height*weight;

equation Y=X; (this isn't exist yet)

run;

quit;

Thank you very much for yours answers.

My problem is the following:

imagine that i have a plot to draw and i want also to add in the graphic an equation

like Y=X

is it possible ?

because for the moment, i work like that but if there is a shorter and easier way to do it, it would be nice

here is my code:

data class;

set sashelp.class end=fin;

x_1= _n_ * 3;

y_1= _n_ * 3;

weight=weight/2;

if _n_ = 1 then do;; x_1=0; y_1=0; end;

if fin then do; x_1=80; y_1=80; end;

run;

goptions reset=all;

title 'is there a shorter way ???';

symbol1 color=red

interpol=join

value=dot

height=3;

symbol2 value=none

color=black

interpol=join

height=2;

axis1 order=(0 to 100 by 20) offset=(0,0)

label=none

major=(height=2) minor=(height=1)

width=3;

axis2 order=(0 to 100 by 20) offset=(0,0)

label=none

major=(height=2) minor=(height=1)

width=3;

proc gplot data=class;

plot height*weight x_1*y_1 / overlay haxis=axis1 vaxis=axis2 ;

run;

quit;

may be is a dream but it would be very nice if the following code exists;

proc gplot data=sashelp.class;

plot height*weight;

equation Y=X; (this isn't exist yet)

run;

quit;

Thank you very much for yours answers.

- Mark as New
- Bookmark
- Subscribe
- RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to deleted_user

11-26-2009 06:12 PM

The alternative is to use annotation, but that's not simpler.

This allows to manage the 2 plots' data separately:

data class;

set sashelp.class;

weight=weight/2;

output;

if _n_ = 1 then do;

do x_1=0 to 100 by 5;

y_1=x_1**1.2 - 1.5*x - 5 ;

output;

end;

end;

run;

This allows to manage the 2 plots' data separately:

data class;

set sashelp.class;

weight=weight/2;

output;

if _n_ = 1 then do;

do x_1=0 to 100 by 5;

y_1=x_1**1.2 - 1.5*x - 5 ;

output;

end;

end;

run;

- Mark as New
- Bookmark
- Subscribe
- RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to deleted_user

11-30-2009 03:03 PM

If you're doing a regression like, you can use the 'regeqn' gplot option, such as:

symbol1 interpol=rcclm95 value=circle cv=red ci=pink co=blue;

proc gplot data=sashelp.class;

plot height*weight=1 / regeqn;

run;

-----

Otherwise, you can use the 'note' option to print some text (equation) such as:

symbol v=dot i=none;

proc gplot data=sashelp.class;

plot height*weight;

note move=(20,80)pct c=blue height=3.5pct font="arial" 'Y=X';

run;

-----

If the equation doesn't have to be on the graph itself, you can put some text in a

'title2' or a 'footnote' statement.

And, of course, you could annotate some text for the equation.

And, if the equation doesn't lend itself to a simple single line of text, you could

create a jpg image containing the equation (created using a fancy word-processor

or other tool) and then annotate that image onto the graph.

-----

symbol1 interpol=rcclm95 value=circle cv=red ci=pink co=blue;

proc gplot data=sashelp.class;

plot height*weight=1 / regeqn;

run;

-----

Otherwise, you can use the 'note' option to print some text (equation) such as:

symbol v=dot i=none;

proc gplot data=sashelp.class;

plot height*weight;

note move=(20,80)pct c=blue height=3.5pct font="arial" 'Y=X';

run;

-----

If the equation doesn't have to be on the graph itself, you can put some text in a

'title2' or a 'footnote' statement.

And, of course, you could annotate some text for the equation.

And, if the equation doesn't lend itself to a simple single line of text, you could

create a jpg image containing the equation (created using a fancy word-processor

or other tool) and then annotate that image onto the graph.

-----

- Mark as New
- Bookmark
- Subscribe
- RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to RobertAllison_SAS

12-04-2009 09:24 AM

Thank you for yours answers