Previous Topic Next topic Print topic


Preprocessor Built-In Functions

A reference to a preprocessor built-in function in input text is executed by the preprocessor only if the built-in function name is active. The functions are explained in the following table:

Function Name Use
COMMENT Converts a CHARACTER expression into a comment.
COMPILETIME Returns a character string containing the current date and time in the following format:

DD MMM YY HH.MM.SS

COUNTER Returns a character string containing a decimal number. The returned number is 00001 for the first invocation and is incremented by one on each successive invocation.
DIMENSION(x,y) Returns a FIXED value specifying the current extent of dimension y of x. The array x can't have less than y dimensions. y must have FIXED type, otherwise it will be converted, and it must be greater than or equal to 1. If omitted, it's value is 1, i.e. you can omit y only if x is one-dimensional.
HBOUND(x,y) Returns a FIXED value specifying the current upper bound of dimension y of x. The array x can't have less than y dimensions. y must have FIXED type, otherwise it will be converted, and it must be greater than or equal to 1. If omitted, it's value is 1, i.e. you can omit y only if x is one-dimensional.
INDEX(x,y,z) Returns a FIXED value indicating the starting position within the character expression x of a substring identical to character expression y. Optionally, z can be the position to start within x. If z is greater than the length of x then INDEX returns 0.
LBOUND(x,y) Returns a FIXED value specifying the lower upper bound of dimension y of x. The array x can't have less than y dimensions. y must have FIXED type, otherwise it will be converted, and it must be greater than or equal to 1. If omitted, it's value is 1, i.e. you can omit y only if x is one-dimensional.
LENGTH(x) Returns a FIXED value specifying the current length of a given character expression x.
PARMSET(x) Used to determine whether a specified parameter has been set on the invocation of a procedure.
QUOTE(x) Returns a CHARACTER string that represents x as a valid quoted string.
SYSADDR Returns a character string of '32' or '64' indicating whether the source has been processed by a 32-bit or 64-bit version of the macro preprocessor.
SYSCHARSET Returns a character string of 'ASCII' or 'EBCDIC' depending on the compile options in effect.
SYSTEM Returns the -systemxxx option that the macro preprocessor was invoked with. The -systemmvs option will return MVS, -systemims - IMS and -systemcics - CICS. If no -systemxxx option was specified, it will return WIN on Windows, AIX on AIX, SOLARIS on Solaris, and LINUX on Red Hat Linux and SUSE Linux.
SUBSTR(x,y[,z]) Returns a substring of the character expression x, starting at position y with length z.
TRANSLATE(s,t,x) Replaces occurrences in the character string s of a character in the specified string x with the corresponding translation character in translation string t and returns the resulting string.
VARIANT Returns a character string specified on the command line.

Examples

Example 1.

%ACTIVATE COMPILETIME;
%DECLARE TOC CHAR;
%TOC = ''''||COMPILETIME||'''';  
PUT LIST ('COMPILED AT' ||TOC); 
PUT SKIP;

The text generated by this example would be as follows:

PUT LIST('COMPILED AT '||' 14 NOV 93 15.53.12'); 
PUT SKIP;

Example 2.

%DECLARE XXX CHAR, COUNTER BUILTIN, I FIXED;
%DO I = 1 TO 4;
%XXX = 'DECLARE NAME_'|| COUNTER || 'FIXED BIN(31);'; 
XXX
%END;

The text generated by this example would be as follows:

DECLARE NAME_00001 FIXED BIN(31); 
DECLARE NAME_00002 FIXED BIN(31) 
DECLARE NAME_00003 FIXED BIN(31) 
DECLARE NAME_00004 FIXED BIN(31)

Example 3 (SYSADDR).

fn: proc() options(main);

%if sysaddr = 64 %then
%do;
         put skip list ('64 bit');         
%end;
%else
%do;
         put skip list ('32 bit');         
%end;
end fn;

Restrictions

COMMENT:

If the literal string contains /* or */ they are not replaced with /> and </.

QUOTE:
If the literal string contains single quotes, it is not replaced with double single quotes ('').
Previous Topic Next topic Print topic