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

Options

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

🔒 This topic is **solved** and **locked**.
Need further help from the community? Please
sign in and ask a **new** question.

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

Posted 12-10-2015 04:46 AM
(2320 views)

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.

1 ACCEPTED SOLUTION

Accepted Solutions

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

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;
```

5 REPLIES 5

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

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

Thanks for your kind reply.

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

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

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

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

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

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/

**Don't miss out on SAS Innovate - Register now for the FREE Livestream!**

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

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.