Data visualization with SAS programming

SAS Graphs 3D

Accepted Solution Solved
Reply
Contributor
Posts: 68
Accepted Solution

SAS Graphs 3D

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
SAS Super FREQ
Posts: 3,475

Re: SAS Graphs 3D

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;

View solution in original post


All Replies
SAS Super FREQ
Posts: 3,475

Re: SAS Graphs 3D

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?

Contributor
Posts: 68

Re: SAS Graphs 3D

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
SAS Super FREQ
Posts: 3,475

Re: SAS Graphs 3D

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;
SAS Super FREQ
Posts: 3,475

Re: SAS Graphs 3D

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

SAS Super FREQ
Posts: 1,104

Re: SAS Graphs 3D

[ Edited ]

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/

 

☑ This topic is SOLVED.

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

Discussion stats
  • 5 replies
  • 483 views
  • 2 likes
  • 3 in conversation