Chapter Contents

Previous

Next
SUBSTR (left of =)

SUBSTR (left of =)



Replaces character value contents

Category: Character


Syntax
Arguments
Details
Examples
See Also

Syntax

SUBSTR(argument,position<,n>)=characters-to-replace

Arguments

argument
specifies a character variable.

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

n
specifies a numeric expression that is the length of the substring that will be replaced.
Restriction: n can not be larger than the length of the expression that remains in argument after position.
Tip: If you omit n SAS uses all of the characters on the right side of the assignment statement to replace the values of argument.

characters-to-replace
specifies a character expression that will replace the contents of argument.
Tip: Enclose a literal string of characters in quotation marks.


Details

When you use the SUBSTR function on the left side of an assignment statement, SAS places the value of argument with the expression on right side. SUBSTR replaces n characters starting at the character 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 =)


Chapter Contents

Previous

Next

Top of Page

Copyright 1999 by SAS Institute Inc., Cary, NC, USA. All rights reserved.