0 votes
in Software Defined Networking by

How SUBSTR function works?

1 Answer

0 votes
by

The SUBSTR function is used to extract substring from a character variable.

The SUBSTR function has three arguments:

SUBSTR ( character variable, starting point to begin reading the variable, number of characters to read from the starting point)

There are two basic applications of the SUBSTR function:

RIGHT SIDE APPLICATION

data _null_;

phone='(312) 555-1212';

area_cd=substr(phone, 2, 3);

put area_cd=;

run;

Result : In the log window, it writes area_cd=312 .

LEFT SIDE APPLICATION

It is used to change just a few characters of a variable.

data _null_ ;

phone='(312) 555-1212' ;

substr(phone, 2, 3)='773' ;

put phone=;

run ;

Result : The variable PHONE has been changed from(312) 555-1212 to (773) 555-1212.

...