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
- /
- SAS Graphs 3D

- Subscribe to 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
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

12-10-2015 04:46 AM

How to plot the below equations in SAS?

x=r*sin(theta)*cos(theta1)

y=r*sin(theta)*sin(theta1)

z=r*cos(theta)

Help needed.

Accepted Solutions

Solution

12-16-2015
11:34 PM

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

12-11-2015 04:14 PM

If you are interested in polar equations (2D), that is easily done. For example, the following create a "polar rose":

```
%let k = 5;
data Rose;
do theta = 0 to 2*constant("pi") by 0.01;
r = cos(&k * theta);
x = r*cos(theta);
y = r*sin(theta);
output;
end;
run;
title "Polar Rose: r = cos(&k theta)";
proc sgplot data=Rose aspect=1;
series x=x y=y;
refline 0 / axis=x;
xaxis min=-1 max=1;
refline 0 / axis=y;
yaxis min=-1 max=1;
run;
```

All Replies

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

12-10-2015 10:54 AM

Spherical coordinate are an alternate coordinate system in which points in 3D space are represented by a distance from the origin, a polar angle, and an azimuthal angle. This coordinate system is used for radially symmetric problems in physics and geometry. In SAS, it arises naturally when you want to plot maps. For maps, the radius of the earth is assumed to be constant, and there are many many projections that you can use to visualize the surface of the earth in the flat plane of the screen.

For a fixed radius, r, your equations form a sphere of radius r. You could draw a 3D scatter plot of the image of a dense grid of (theta1, theta) values to see what it looks like, but since all spheres look like spheres there really isn't much point in graphing it.

If you tell us your application, we might be able to provide more information. Do you have 3D data that you are trying to model? Are you trying to estimate the radius of "best fit" for a set of data points? Are you trying to visualize 3D data?

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

12-11-2015 12:16 AM

Thanks for your kind reply.

I don't have any data, was thinking how could we plot polar equations in SAS.

Solution

12-16-2015
11:34 PM

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

12-11-2015 04:14 PM

If you are interested in polar equations (2D), that is easily done. For example, the following create a "polar rose":

```
%let k = 5;
data Rose;
do theta = 0 to 2*constant("pi") by 0.01;
r = cos(&k * theta);
x = r*cos(theta);
y = r*sin(theta);
output;
end;
run;
title "Polar Rose: r = cos(&k theta)";
proc sgplot data=Rose aspect=1;
series x=x y=y;
refline 0 / axis=x;
xaxis min=-1 max=1;
refline 0 / axis=y;
yaxis min=-1 max=1;
run;
```

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

12-16-2015 10:30 AM

I wrote a blog post on the subject of polar roses: "Lo, how a polar rose e'er blooming."

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

12-16-2015 01:44 PM - edited 12-16-2015 01:46 PM

Earlier in the year, I wrote an article on creating 3D graphs using SAS 9.4 SGPLOT. This includes a macro that can handle a simple 3D scatterplot, and a way to animate it. You might find some useful ideas here.

http://blogs.sas.com/content/graphicallyspeaking/2015/03/10/a-3d-scatter-plot-macro/

http://blogs.sas.com/content/graphicallyspeaking/2015/03/16/a-3d-scatter-plot-animation-macro/