Dear All,
Aside from simulating data in a data step and then use a procedure such as PLOT, GPLOT, SGPLOT, etc. is there any way to graph a mathematical function (say y = x**2) by simply inputting the function and requesting a graph?
For me, the go-to method was the above, i.e. simulate the data first and then plot it, but I thought there might be some function out there (or something in either EG or IML Studio perhaps) that would do the trick.
Thank you for your input
@PGStats shows the usual method. Since you mentioned IML, I'm thinking that perhaps your function is defined by a function module? If so, you can use a similar approach from inside SAS/IML:
proc iml; start MyFunc(x); return( x##2 ); finish; t = do(-2, 2, 0.1); call series(t, MyFunc(t));
From inside SAS/IML Studio you can get an interactive plot by using
LinePlot.Create("function plot", t, MyFunc(t));
Took me about 30 seconds to write
data function;
do x = -1 to 4 by 0.05;
y = x**2;
output;
end;
run;
proc sgplot data=function;
series x=x y=y;
run;
and get a decent basic graph. SAS software (GTL, SG, SAS/GRAPH, even JMP) doesn't graph user-specified functions, only data.
Just to clear up a misconception, JMP will plot functions.
See the Formula Element in Graph Builder or for more flexibility the Y Function() in graphic scripting.
For functions in more than two dimensions the various Profilers in JMP offer the ultimate flexibility.
-Jeff
@PGStats shows the usual method. Since you mentioned IML, I'm thinking that perhaps your function is defined by a function module? If so, you can use a similar approach from inside SAS/IML:
proc iml; start MyFunc(x); return( x##2 ); finish; t = do(-2, 2, 0.1); call series(t, MyFunc(t));
From inside SAS/IML Studio you can get an interactive plot by using
LinePlot.Create("function plot", t, MyFunc(t));
Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.
Register today!Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.
Find more tutorials on the SAS Users YouTube channel.