CALL SYMPUTX Routine

Assigns a value to a macro variable, and removes both leading and trailing blanks.

Category: Macro

Syntax

CALL SYMPUTX(macro-variable, value <,symbol-table> );

Required Arguments

macro-variable

can be one of the following:

  • a character string that is a SAS name, enclosed in quotation marks.
  • the name of a character variable whose values are SAS names.
  • a character expression that produces a macro variable name. This form is useful for creating a series of macro variables.
a character constant, variable, or expression. Leading and trailing blanks are removed from the value of name, and the result is then used as the name of the macro variable.

value

specifies a character or numeric constant, variable, or expression. If value is numeric, SAS converts the value to a character string using the BEST. format and does not issue a note to the SAS log. Leading and trailing blanks are removed, and the resulting character string is assigned to the macro variable.

Optional Argument

symbol-table

specifies a character constant, variable, or expression. The value of symbol-table is not case sensitive. The first non-blank character in symbol-table specifies the symbol table in which to store the macro variable. The following values are valid as the first non-blank character in symbol-table:

G specifies that the macro variable is stored in the global symbol table, even if the local symbol table exists.
L specifies that the macro variable is stored in the most local symbol table that exists, which will be the global symbol table, if used outside a macro.
F specifies that if the macro variable exists in any symbol table, CALL SYMPUTX uses the version in the most local symbol table in which it exists. If the macro variable does not exist, CALL SYMPUTX stores the variable in the most local symbol table.
Note: If you omit symbol-table or if symbol-table is blank, CALL SYMPUTX stores the macro variable in the same symbol table as does the CALL SYMPUT routine.

Details

CALL SYMPUTX is similar to CALL SYMPUT except that
  • CALL SYMPUTX does not write a note to the SAS log when the second argument is numeric. CALL SYMPUT, however, writes a note to the log stating that numeric values were converted to character values.
  • CALL SYMPUTX uses a field width of up to 32 characters when it converts a numeric second argument to a character value. CALL SYMPUT uses a field width of up to 12 characters.
  • CALL SYMPUTX left-justifies both arguments and trims trailing blanks. CALL SYMPUT does not left-justify the arguments, and trims trailing blanks from the first argument only. Leading blanks in the value of name cause an error.
  • CALL SYMPUTX enables you to specify the symbol table in which to store the macro variable, whereas CALL SYMPUT does not.

Example: Using CALL SYMPUTX

The following example shows the results of using CALL SYMPUTX.
data _null_;
   call symputx('  items  ', '   leading and trailing blanks removed   ',
                'lplace');
   call symputx('  x   ', 123.456);
run;
%put items=!&items!;
%put x=!&x!;
The following lines are written to the SAS log:
   ----+----1----+----2----+----3----+----4----+----5
   items=!leading and trailing blanks removed!
   x=!123.456!

See Also

Functions:
CALL Routines: