| Procedure features: | 
| PROC
FCMP functions
 |  | Other procedures
 
|  | PROC TEMPLATE |  |  | PROC SGRENDER |  |  | 
The following example shows how to define
functions that define new
curve types (oscillate and oscillateBound). These functions can be used in
a GTL EVAL function to compute new columns that are presented with a seriesplot
and bandplot.
|  | proc fcmp outlib=sasuser.funcs.curves;
   function oscillate(x,amplitude,frequency);
         if amplitude le 0 then amp=1; else amp=amplitude;
	      if frequency le 0 then freq=1; else freq=frequency;
         y=sin(freq*x)*constant("e")**(-amp*x); 
         return (y);
  endsub; | 
|  |  function oscillateBound(x,amplitude);
       if amplitude le 0 then amp=1; else amp=amplitude;
       y=constant("e")**(-amp*x); 
       return (y);
  endsub;
 run;
 | 
|  | 
 options cmplib=sasuser.funcs;
  
data range;
   do Time=0 to 2 by .01;
   output;
   end;
run;
 | 
|  | proc template ;
   define statgraph damping;
   dynamic X AMP FREQ;
   begingraph;
       entrytitle "Damped Harmonic Oscillation";
       layout overlay / yaxisopts=(label="Displacement");
          if (exists(X) and exists(AMP) and exists(FREQ)) 
	            bandplot x=X  limitlower=eval(-oscillateBound(X,AMP)) 
                limitupper=eval(oscillateBound(X,AMP));
                seriesplot x=X y=eval(oscillate(X,AMP,FREQ));
	      endif;
	    endlayout;
   endgraph;
   end;
   run; | 
|  |  ods html;  | 
|  |  proc sgrender data=range template=damping;
      dynamic x="Time" amp=10 freq=50 ;
 run; | 
|  |      ods html close; | 
![[untitled graphic]](images/fcmp-gtl.gif)
 
Copyright © 2010 by SAS Institute Inc., Cary, NC, USA. All rights reserved.