Stata 11 help for substr

help substr() -------------------------------------------------------------------------------

Title

[D] functions -- Functions

String function

substr(s,n1,n2) Domain s: strings Domain n1: integers 1 to 244 and -1 to -244 Domain n2: integers 1 to 244 and -1 to -244 Range: strings Description: returns the substring of s, starting at column n1, for a length of n2. If n1 < 0, n1 is interpreted as distance from the end of the string; if n2 = . (missing), the remaining portion of the string is returned.

substr("abcdef",2,3) = "bcd" substr("abcdef",-3,2) = "de" substr("abcdef",2,.) = "bcdef" substr("abcdef",-3,.) = "def" substr("abcdef",2,0) = "" substr("abcdef",15,2) = ""

Also see

Manual: [D] functions

Help: [D] functions, [D] functions (string functions)


© Copyright 1996–2009 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index