STRING subcommand (REPORT command)

STRING creates a temporary string variable by concatenating variables and user-specified strings. These variables exist only within the REPORT procedure.

  • The minimum specification is a name for the string variable followed by a variable name or a user-specified string enclosed in parentheses.
  • The name assigned to the string variable must be unique.
  • Any combination of string variables, numeric variables, and user-specified strings can be used in the parentheses to define the string.
  • Keyword TO cannot be used within the parentheses to imply a variable list.
  • More than one string variable can be defined on STRING.
  • If a case has a missing value for a variable within the parentheses, the variable passes the missing value to the temporary variable without affecting other elements specified.
  • A string variable defined in REPORT cannot exceed the system page width.
  • String variables defined on STRING can be used on VARIABLES or BREAK.

The following options can be used to specify how components are to be concatenated:

(width). Width of the preceding variable within the string. The default is the dictionary width of the variable. The maximum width for numeric variables within the string definition is 16. The maximum width for a string variable is the system page width. If the width specified is less than that required by the value, numeric values are displayed as asterisks and string values are truncated. If the width exceeds the width of a value, numeric values are padded with zeros on the left and string values are padded with blanks on the right.

(BLANK). Left-pad values of the preceding numeric variable with blanks. The default is to left-pad values of numeric variables with zeros. If a numeric variable has a dollar or comma format, it is automatically left-padded with blanks.

‘literal’ . User-specified string. Any combination of characters can be specified within quotes.

Example

 /STRING=JOB1(AVAR NVAR)
         JOB2(AVAR(2) NVAR(3))
         JOB3(AVAR(2) NVAR(BLANK) (4))
  • STRING defines three string variables to be used within the report.
  • Assume that AVAR is a string variable read from a four-column field using keyword FIXED on DATA LIST and that NVAR is a computed numeric variable with the default format of eight columns with two implied decimal places.
  • If a case has value KJ for AVAR and value 241 for NVAR, JOB1 displays the value ‘KJ 00241.00’, JOB2 the value ‘KJ241’, and JOB3 the value ‘KJ 241’. If NVAR has the system-missing value for a case, JOB1 displays the value ‘KJ’.

Example

  /STRING=SOCSEC(S1 '-' S2 '-' S3)
  • STRING concatenates the three variables S1, S2, and S3, each of which contains a segment of the social security number.
  • Hyphens are inserted between the segments when the values of SOCSEC are displayed.
  • This example assumes that the variables S1, S2, and S3 were read from three-column, two-column, and four-column fields respectively, using the keyword FIXED on DATA LIST. These variables would then have default format widths of 3, 2, and 4 columns and would not be left-padded with zeros.