Command Reference : String and Date Function Reference
  
 
@instr
Find substring position.
Syntax: @instr(str1, str2[, n])
str1: string
str2: string
n: (optional) integer
Return: integer
Finds the starting position of the n-th occurrence of the target string str2 in the string str1.
By default, the function returns the location of the first instance of str2 in str1, but you may provide the optional integer n to change the occurrence.
If the target string is not found, @instr will return a 0.
Examples
string sval = "1.23415"
@instr("1.23415", "34")
@instr(sval, "34")
return the value 4, since the substring “34” appears beginning in the fourth character of the base string.
If ALPHA1 is an alpha series,
series s1 = @instr(alpha1, "34", 2)
fills the series with the 2nd instance of the string “34” in each string in ALPHA1, for each observation in the workfile sample.
If SVEC1 is an svector,
vector v1 = @instr(svec1, sval)
fills the vector with the location of the contents of the string SVAL for each element of SVEC1.
Cross-references
See also @rinstr for finding substrings starting from the end of the string, and @mid for extracting substrings.