Help using Base SAS procedures

Using the FCMP Procedure to Store a Formula in a Function

Accepted Solution Solved
Reply
Frequent Contributor
Posts: 90
Accepted Solution

Using the FCMP Procedure to Store a Formula in a Function

Hello Everyone,

So I have the following program in my homework:

data test;

   set orion.order_fact(keep=Employee_ID Quantity

      Total_Retail_Price);

   if Quantity>2 then Kick_Back_Amt=Quantity*Total_Retail_Price/5;

   else Kick_Back_Amt=Quantity*Total_Retail_Price/10;

run;

proc print data=test(obs=5);

run;

I have to take this program and create a PROC FCMP where I have a formula stored that I can query later.

This is my program so far:

options cmplib=orion.functions;

proc fcmp outlib=work.functions.Marketing;

function kb(Quantity, Total_Retail_Price) $50;

  if Quantity>2 then return (Quantity*Total_Retail_Price/5);

  else return (Quantity*Total_Retail_Price/10);

endsub;

run;

quit;

data kick_backs;

   set orion.order_fact;

   Kick_Back_Amt=kb(Quantity, Total_Retail_Price);

run;

proc print data=kick_backs (obs=5);

run;

However, when I try to access my formula, I get the following:

472  options cmplib=orion.functions;

473  proc fcmp outlib=work.functions.Marketing;

474  function kb(Quantity1, Total_Retail_Price) $50;

475    if Quantity>2 then return (Quantity1*Total_Retail_Price/5);

NOTE: Numeric value converted to character.

476    else return (Quantity1*Total_Retail_Price/10);

NOTE: Numeric value converted to character.

477  endsub;

478  run;

NOTE: Function kb saved to work.functions.Marketing.

NOTE: PROCEDURE FCMP used (Total process time):

      real time           0.20 seconds

      cpu time            0.03 seconds

479  quit;

480

481  /*part c*/

482  data kick_backs;

483     set orion.order_fact;

484     Kick_Back_Amt=kb(Quantity, Total_Retail_Price);

484     Kick_Back_Amt=kb(Quantity, Total_Retail_Price);

                      --

                      68

ERROR 68-185: The function KB is unknown, or cannot be accessed.

485  run;

I am not sure where I am going wrong with my program, but if someone could take a look at it and let me know, it will be greatly appreciated.

Thanks!

Alisa


Accepted Solutions
Solution
‎05-07-2012 02:55 PM
Frequent Contributor
Posts: 90

Re: Using the FCMP Procedure to Store a Formula in a Function

Never mind....just needed to change

options cmplib=orion.functions; to work.functions.

View solution in original post


All Replies
Solution
‎05-07-2012 02:55 PM
Frequent Contributor
Posts: 90

Re: Using the FCMP Procedure to Store a Formula in a Function

Never mind....just needed to change

options cmplib=orion.functions; to work.functions.

☑ This topic is solved.

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

Discussion stats
  • 1 reply
  • 124 views
  • 0 likes
  • 1 in conversation