Turn on suggestions

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

Showing results for

- Home
- /
- Programming
- /
- Graphics
- /
- adding an equation to draw to a plot statement

Options

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

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

Posted 11-26-2009 11:32 AM
(628 views)

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.

3 REPLIES 3

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

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
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

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
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

Thank you for yours answers

Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.

**If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website. **

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.