The FCMP Procedure |
Overview of PROC FCMP and DATA Step Differences |
PROC FCMP was originally developed as a programming language for several SAS/STAT, SAS/ETS, and SAS/OR procedures. Because the implementation is not identical to the DATA step, differences exist between the two languages. The following section describes some of the differences between PROC FCMP and the DATA step.
Differences between PROC FCMP and the DATA Step |
The ABORT statement in PROC FCMP does not accept arguments.
The ABORT statement is not valid within functions or subroutines in PROC FCMP. It is valid only in the main body of the procedure.
PROC FCMP uses parentheses after a name to represent a function call. When referencing an array, the recommended practice is to use square brackets [ ] or curly braces { }. For an array named ARR, the code would be ARR[i] or ARR{i} . PROC FCMP limits the number of dimensions for an array to six.
For more information about the differences in the ARRAY statement for PROC FCMP, see Details.
PROC FCMP does not support the DATA and the OUTPUT statements for creating and writing to an output data set. It does not support the SET, MERGE, UPDATE, or MODIFY statements for data set input. Data is typically transferred into and out of PROC FCMP routines by using parameters. If a large amount of data needs to be transferred, you can pass arrays to a PROC FCMP routine.
When you use the DATA step debugger, PROC FCMP routines perform like any other routine. That is, it is not possible to step into the function when debugging. Instead, use a PUT statement within the routine.
The following type of DO statement is supported by PROC FCMP:
do i = 1, 2, 3;
The DO statement in PROC FCMP does not support character loop control variables. You can execute the following code in the DATA step, but not in PROC FCMP:
do i = 'a', 'b', 'c';
The DO statement does not support a character index variable; therefore, the following code is not supported in PROC FCMP:
do i = 'one','two','three';
PROC FCMP supports the PUT and FILE statements, but the FILE statement is limited to LOG and PRINT destinations. There are no INFILE or INPUT statements in PROC FCMP.
An IF expression enables IF/THEN/ELSE conditions to be evaluated within an expression. IF expressions are supported by PROC FCMP but not by the DATA step. You can simplify some expressions with IF expressions by not having to split the expression among IF/THEN/ELSE statements. For example, the following two pieces of code are equivalent, but the IF expression (the first example) is not as complex:
The alternative to IF expressions are expressions. This means that parentheses are used to group operations instead of DO/END blocks.
The syntax of the PUT statement is similar in PROC FCMP and in the DATA step, but their operations can be different. In PROC FCMP, the PUT statement is typically used for program debugging. In the DATA step, the PUT statement is used as a report or file creation tool, as well as a debugging tool. The following list describes other differences:
The PUT statement in PROC FCMP does not support line pointers, format modifiers, column output, factored lists, iteration factors, overprinting, the _INFILE_ option, or the special character $. It does not support features that are provided by the FILE statement options, such as DLM= and DSD.
The PUT statement in PROC FCMP supports evaluating an expression and writing the result by placing the expression in parentheses. The DATA step, however, does not support the evaluation of expressions in a PUT statement. In the following example for PROC FCMP, the expressions x/100 and sqrt(y)/2 are evaluated and the results are written to the SAS log:
put (x/100) (sqrt(y)/2);
Because parentheses are used for expression evaluation in PROC FCMP, they cannot be used for variable or format lists as in the DATA step.
The PUT statement in PROC FCMP does not support subscripted array names unless they are enclosed in parentheses. For example, the statement PUT (A[i]); writes the i-th element of the array A, but the statement PUT A[i]; results in an error message.
An array name can be used in a PUT statement without superscripts. Therefore, the following statements are valid:
The PUT statement in PROC FCMP follows the output of each item with a space, which is similar to list mode output in the DATA step. Detailed control over column and line position are supported to a lesser extent than in the DATA step.
The PUT statement in PROC FCMP supports the print item _PDV_, and prints a formatted listing of all of the variables in the routine's program data vector. The statement PUT _PDV_; prints a much more readable listing of the variables than is printed by the statement PUT _ALL_; .
The WHEN and OTHERWISE statements allow more than one target statement. That is, DO/END groups are not necessary for multiple WHEN statements. The following is an example:
SELECT; WHEN(expression-1) statement-1; statement-2; WHEN (expression-2) statement-3; statement-4; END;
Additional Features in PROC FCMP |
PROC REPORT uses the DATA step to evaluate compute blocks. Because the DATA step can call PROC FCMP routines, you can also call these routines from PROC REPORT compute blocks.
The FCmp Function Editor is an application for traversing packages of functions and is built into the SAS Explorer. You can access the FCmp Function Editor from the Solutions menu of an interactive SAS session. For more information, see The FCmp Function Editor.
PROC FCMP uses a SOLVE function for computing implicit values of a function. For more information, see The SOLVE Function.
Many Microsoft Excel functions, not typically available in SAS, are implemented in PROC FCMP. You can find these functions in the sashelp.slkwxl data set.
Copyright © 2010 by SAS Institute Inc., Cary, NC, USA. All rights reserved.