Command Reference : String and Date Function Reference
  
 
@mid
Middle substring.
Syntax: @mid(str, n1[, n2])
str: string
n1: integer
n2: (optional) integer
Return: string
Returns n2 characters from str, starting at location n1 and continuing for n2 characters to the right. If you omit n2, it will return all of the remaining characters in the string.
Examples
The command
string s1 = @mid("I doubt it", 5)
assigns “ubt it” to the string object S1, while
string s2 = @mid("I doubt it", 5, 2)
assigns “ub” to S2.
If ALPHA1 is an alpha series,
alpha a1 = @mid(alpha1, 7)
returns the characters beginning with the 7th from the string values of ALPHA1 for each observation in the workfile sample.
If LETTER_ID is a numeric series with integer values from 1 to 26, then
string alphabet = "abcdefghijklmnopqrstuvwxyz"
alpha letter = @mid(alphabet, letter_id, 1)
will lookup the letter associated with each value of LETTER_ID for observations in the workfile sample.
If SVEC1 is an string vector,
svector sv1 = @mid(svec1, 12, 5)
returns an svector beginning at the 12th for 5 characters for each element of SVEC1.
Cross-references
See also @wmid, @left and @right.