Previous Page | Next Page

The FCMP Procedure

Example 2: Creating a CALL Routine and a Function


Procedure features:

PROC FCMP statement option

OUTLIB=

OUTARGS statement


This example shows how to use PROC FCMP to create and store CALL routines and functions.


Program

 Note about code
proc fcmp outlib = sasuser.exsubs.pkt1;
 Note about code
   subroutine calc_years(maturity, current_date, years);
      outargs years;
      years = (maturity - current_date) / 365.25;
   endsub;
 Note about code
   function garkhprc (type$, buysell$, amount,
                      E, t, S, rd, rf, sig);
      if buysell = "Buy" then sign = 1.;
      else do;
         if buysell = "Sell" then sign = -1.;
         else sign = .;
      end;

      if type = "Call" then
         garkhprc = sign * amount 
                         * garkhptprc (E, t, S, rd, rf, sig);
      else do;
         if type = "Put" then
            garkhprc = sign * amount 
                            * garkhptprc (E, t, S, rd, rf, sig);
         else garkhprc = .;
      end;
 Note about code
      return (garkhprc);
   endsub;
 Note about code
run;

SAS Log

NOTE: Function garkhprc saved to sasuser.exsubs.pkt1.
NOTE: Function calc_years saved to sasuser.exsubs.pkt1.

Previous Page | Next Page | Top of Page