CALL SYMPUTX Routine


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 >);

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.

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 might be the global symbol table.

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.

Comparisons

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.

Examples

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 and CALL Routines:

  • 'SYMGET Function' on page 844

  • 'CALL SYMPUT Routine' on page 403




SAS 9.1 Language Reference Dictionary, Volumes 1, 2 and 3
SAS 9.1 Language Reference Dictionary, Volumes 1, 2 and 3
ISBN: N/A
EAN: N/A
Year: 2004
Pages: 704

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net