Previous PageNext Page

Example 8: Operations on Character Values
The SUBSTR function takes a substring or portion of a character variable. You may have seen this function in other programming languages as: MID, or MIDDLE.
Assuming OLD has the variable ID with these two values: 427NJ and 125NY.
Data new;
Set old;
Length State $2;
State = SUBSTR(ID,4,2);
Run;
The values of STATE will be: NJ and NY.

SUBSTR function
SUBSTR (char_variable, starting_position, length);

Question: Is the length statement needed?

Previous PageTable Of ContentsNext Page