SUBSTR (left of) Function


SUBSTR (left of =) Function

Replaces character value contents

Category: Character

Syntax

SUBSTR ( variable, position <, length >)= characters -to-replace

Arguments

variable

  • specifies a character variable.

position

  • specifies a numeric expression that is the beginning character position.

length

  • specifies a numeric expression that is the length of the substring that will be replaced .

  • Restriction: length cannot be larger than the length of the expression that remains in variable after position .

  • Tip: If you omit length , SAS uses all of the characters on the right side of the assignment statement to replace the values of variable .

characters-to-replace

  • specifies a character expression that will replace the contents of variable .

  • Tip: Enclose a literal string of characters in quotation marks.

Details

If you use an undeclared variable, it will be assigned a default length of 8 when the SUBSTR function is compiled.

When you use the SUBSTR function on the left side of an assignment statement, SAS replaces the value of variable with the expression on the right side. SUBSTR replaces length characters starting at the character that you specify in position .

Examples

SAS Statements

Results

  a='KIDNAP';   substr(a,1,3)='CAT';   put a;  
  CATNAP  
  b=a;   substr(b,4)='TY';   put b;  
  CATTY  

See Also

Function:

  • 'SUBSTR (right of =) Function' on page 838




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