Creating custom SAS functions with the FCMP Procedure


The SAS System provides users with the ability to create, store and access custom functions using the Function Compiler (FCMP) procedure.  Once defined with PROC FCMP, a user-defined function can be used, or called, just like any other SAS function in the SAS System. This powerful capability gives users the ability to process and maintain code as independent and reusable subroutines. PROC FCMP functions are stored in a data set and can be used in a DATA step, a WHERE statement, with Output Delivery System (ODS), and numerous procedures including PROC CALIS, PROC COMPUTAB, PROC GENMOD, PROC MODEL, PROC NLIN, PROC NLMIXED, PROC NLP, PROC PHREG, PROC REPORT, PROC SIMILARITY, and PROC SQL. The following example illustrates the syntax used to create and call the custom user-defined function with the FCMP procedure.

Example code:


 Output results:

To learn more about Kirk Lafler and to read a free chapter from his book PROC SQL: Beyond the Basics Using SAS, visit his author page.


About Author

Kirk Paul Lafler

Consultant and founder of Software Intelligence Corporation

Kirk Paul Lafler, consultant and founder of Software Intelligence Corporation, has been a SAS user since 1979. As a SAS Certified Professional, Kirk provides IT consulting services and training to SAS users around the world. He is the author PROC SQL: Beyond the Basics Using SAS, Second Edition. He’s also written more than 100 peer-reviewed technical articles and writes the popular SAS tips column, "Kirk's Korner, " that appears in several SAS Users Group newsletters. Kirk is a frequent speaker at SAS Users Group meetings.

Back to Top