Help using Base SAS procedures

Proc fcmp

Accepted Solution Solved
Reply
Contributor
Posts: 68
Accepted Solution

Proc fcmp

While working with proc fcmp procedure how to assign library with "outlib=" options. Is there a standard way.

 

Getting error with below codes

 

proc fcmp outlib;
function lb2kg(lb);
kg = lb/2.2;
return (kg);
endsub;
run;

 

 

Why do we need the option cmplib. What does the below code says 

 

"options cmplib=(funcsol.functions);"

 

Need help.


Accepted Solutions
Solution
‎02-29-2016 12:25 AM
Super User
Posts: 5,255

Re: Proc fcmp

It's a bit confusing that the options is called "outlib", when you are referring to data set observations in a logical structure called package.

So you won't see the three level name somewhere in the SAS library, or by using proc datasets/contents.

But if you open the data set (two level name) you will see the package (several observations).

Data never sleeps

View solution in original post


All Replies
Super User
Posts: 6,928

Re: Proc fcmp

OUTLIB= specifies a location where compiled finctions/subroutines will be stored

Syntax is

outlib=mylib.function

where mylib denotes a library that is currently assigned and function is the name of a member of type cmpsub in that library.

 

The system option CMPLIB= lets you specify such a member from which functions/subroutines shall be included.

 

See

PROC FCMP Statement

and

CMPLIB= System Option

 

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
Contributor
Posts: 68

Re: Proc fcmp

I came across we have to specify the three level name of a library entry using the formats libref.catalog.paackage. This option
is mandatory when you use the OUTLIB= option

 

But I can able to see only two levels, can you please help me more on this.

 

Kafeel

Solution
‎02-29-2016 12:25 AM
Super User
Posts: 5,255

Re: Proc fcmp

It's a bit confusing that the options is called "outlib", when you are referring to data set observations in a logical structure called package.

So you won't see the three level name somewhere in the SAS library, or by using proc datasets/contents.

But if you open the data set (two level name) you will see the package (several observations).

Data never sleeps
Occasional Contributor
Posts: 17

Re: Proc fcmp

While creating the user defined functions by using PROC FCMP, we have to mention the location where the created function should be saved. It shoud be in the form of three level. First level indicates library name, second level indicated dataset name and third level indicated package name.

 

Within the library, each function or subroutines is associated with a "Package".

Package is a group of functions and subroutines.

Function library can contain multiple packages.

 

Example1;

/* Declaring the function */

proc fcmp outlib=sasuser.study.demo;

   function study_day(intervention_date, event_date);

       n=event_date-intervention_date;

       if n <= 0 then

       n=n+1;

       return (n);

   endsub;

Run;

options cmplib=sasuser.funcs;

data Ae;

   start = '15Feb2006'd;

   today = '27Mar2006'd;

   sd = study_day(start, today);

run

 

 

☑ This topic is SOLVED.

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

Discussion stats
  • 4 replies
  • 513 views
  • 5 likes
  • 4 in conversation