You can create a new function whenever
you have a library, data set, or package selected. To create a new
function in a library, position your cursor on the library into which
the new function will be added. Right-click the library and select
New
Function. You can also select
FileNew Function from the menu
or click
in the upper left corner below the menu bar. The
following window appears:
The upper right corner
of the window contains two buttons:
Function and
Subroutine.
Click one of the buttons depending on whether you want to create a
new function or a new subroutine.
The
newElement window
contains the following fields:
specifies the name
of the new function.
describes the new function.
specifies the library
that will contain the new function. Enter the name of the library,
or click the down arrow in the Library field
to select a library.
specifies the data
set that will contain the new function. Enter the name of the data
set, or click the down arrow in the Data Set field
to select a data set. If you do not specify a value, the value in
this field defaults to Functions.
specifies the name
of the package that will contain the new function. Enter the name
of the package, or click the down arrow in the Package field
to select a package. The Package field is
a required field. If you do not specify a value, the value in this
field defaults to Package.
enables you to group
functions within a given package. Four predefined kind groupings are
available and are typically used with SAS Risk Management:
-
-
Risk Factor Transformation
-
-
You can use one of
these four groupings, or enter your own kind value in the
Kind field.
The function tree in the left pane groups the functions in a package
into their kind grouping, if you specified a value for
Kind.
specifies libraries
that contain SAS code that you want to include in your function.
specifies the arguments
that you use as input to the function.
specifies whether the
function supports a variable number of arguments.
specifies whether the
function returns a character or numeric value.
is the area in the
window in which you code your function.
Three buttons are located
at the bottom left of the
newElement window:
provides you with an
area in which to write descriptive information (name of the new function,
list of include libraries, input parameters, and so on) about your
function. You code your new function in the Function Body section.
The Details tab is selected by default.
enables you to view
the function that you have written. The SAS Code selection
provides read-only capabilities.
enables you to check
the syntax for the code that you have written. If the syntax is correct,
a dialog box appears stating that the syntax is correct. If the syntax
contains an error, a dialog box appears that describes the error.
An error message also appears in the lower left bar of the window.
Syntax errors are written to the log, which you can access from the
ViewShow Log menu.
When you enter information
in the descriptive portion of the
Details tab,
as well as in the
Function Body section,
the information is converted to SAS code that you can see when you
select the
SAS Code button.