The NLIN procedure now uses a compiler that is different from the DATA step compiler. The compiler was changed so that analytical derivatives could be computed automatically. For the most part, the syntax accepted by the old NLIN procedure can be used in the new NLIN procedure. However, there are several differences that should be noted:
You cannot specify a character index variable in the DO statement, and you cannot specify a character test in the IF statement.
Thus do i=1,2,3;
is supported, but do i=’ONE’,’TWO’,’THREE’;
is not supported. And if ’THIS’ < ’THAT’ then …;
is supported, but if ’THIS’ THEN …;
is not supported.
The PUT statement, which is used mostly for program debugging in PROC NLIN, supports only some of the features of the DATA step PUT statement, and it has some new features that the DATA step PUT statement does not.
The PUT statement does not support line pointers, factored lists, iteration factors, overprinting, the _INFILE_ option, the ‘:’ format modifier, or the symbol ‘$’.
The PUT statement does support expressions inside of parentheses. For example, put (sqrt(X));
produces the square root of X.
The PUT statement also supports the option _PDV_ to display a formatted listing of all the variables in the program. The statement
put _pdv_;
prints a much more readable listing of the variables than put _all_;
does.
You cannot use the ‘*’ subscript, but you can specify an array name in a PUT statement without subscripts. Thus, array a …; put a;
is acceptable, but put a[*];
is not. The statement put a;
displays all the elements of the array a
. The put a=;
statement displays all the elements of A with each value labeled by the name of the element variable.
You can specify more than one target statement in the WHEN and OTHERWISE statements. That is, DO/END groups are not necessary
for multiple WHEN statements, such as select; when(exp1); stmt1; stmt2; when(exp2); stmt3; stmt4; end;
.
You can specify only the options LOG, PRINT, and LIST in the FILE statement.
The RETAIN statement retains only values across one pass through the data set. If you need to retain values across iterations, use the CONTROL statement to make a control variable.
The ARRAY statement in PROC NLIN is similar to, but not the same as, the ARRAY statement in the DATA step. The ARRAY statement is used to associate a name (of no more than 8 characters) with a list of variables and constants. The array name can then be used with subscripts in the program to refer to the items in the list.
The ARRAY statement supported by PROC NLIN does not support all the features of the DATA step ARRAY statement. You cannot specify implicit indexing variables; all array references must have explicit subscript expressions. You can specify simple array dimensions; lower bound specifications are not supported. A maximum of six dimensions are accepted.
On the other hand, the ARRAY statement supported by PROC NLIN does accept both variables and constants as array elements.
In the following statements, b
is a constant array and c
is a variable array. Note that the constant array elements cannot be changed with assignment statements.
proc nlin data=nld; array b[4] 1 2 3 4; /* Constant array */ array c[4] ( 1 2 3 4 ); /* Numeric array with initial values */ b[1] = 2; /* This is an ERROR, b is a constant array*/ c[2] = 7.5; /* This is allowed */
Both dimension specification and the list of elements are optional, but at least one must be specified. When the list of elements is not specified, or fewer elements than the size of the array are listed, array variables are created by suffixing element numbers to the array name to complete the element list.
If the array is used as a pure array in the program rather than a list of symbols (the individual symbols of the array are
not referenced in the code), the array is converted to a numerical array. A pure array is literally a vector of numbers that
are accessed only by index. Using these types of arrays results in faster derivatives and compiled code. The assignment to
c1
in the following statements forces the array to be treated as a list of symbols:
proc nlin data=nld; array c[4] ( 1 2 3 4 ); /* Numeric array with initial values */ c[2] = 7.5; /* This is C used as a pure array */ c1 = -92.5; /* This forces C to be a list of symbols */