BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
KafeelBasha
Quartz | Level 8

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
Rick_SAS
SAS Super FREQ

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

5 REPLIES 5
Rick_SAS
SAS Super FREQ

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?

KafeelBasha
Quartz | Level 8

Thanks for your kind reply.

 

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

 

Rick_SAS
SAS Super FREQ

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;
Rick_SAS
SAS Super FREQ

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

Jay54
Meteorite | Level 14

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/

 

sas-innovate-2024.png

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.

 

Register now!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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