Example: air traffic controller

Title stata.com String functions

FunctionsContentsFunctionsReferencesAlso seeContentsabbrev(s,n)names, abbreviated to a length ofnchar(n)the character corresponding toASCIIor extendedASCII coden;""ifnis not in the domaincollatorlocale(loc,type)the most closely related locale supported byICUfromlociftypeis1; the actual locale where the collation data comes from iftypeis2collatorversion(loc)the version String of a collator based on localelocindexnot(s1,s2)the position inASCII strings1of the first character ofs1not foundinASCII strings2, or0if all characters ofs1are found ins2plural(n,s)the plural ofsifn6= 1plural(n,s1,s2)the plural ofs1, as modified by or replaced withs2, ifn6= 1real(s)sconverted to numeric ormissingregexm(s,re)performs a match of a regular expression and evaluates to1if regularexpressionr

substr(s,n 1,n 2) the substring of s, starting at n 1, for a length of n 2 tobytes(s,n) escaped decimal or hex digit strings of up to 200 bytes of s uchar(n) the Unicode character corresponding to Unicode code point nor an empty string if nis beyond the Unicode code-point range udstrlen(s) the number of display columns needed to display the ...

Tags:

  Functions, String, Substr, String functions

Information

Domain:

Source:

Link to this page:

Please notify us if you found a problem with this document:

Other abuse

Advertisement

Transcription of Title stata.com String functions

1 FunctionsContentsFunctionsReferencesAlso seeContentsabbrev(s,n)names, abbreviated to a length ofnchar(n)the character corresponding toASCIIor extendedASCII coden;""ifnis not in the domaincollatorlocale(loc,type)the most closely related locale supported byICUfromlociftypeis1; the actual locale where the collation data comes from iftypeis2collatorversion(loc)the version String of a collator based on localelocindexnot(s1,s2)the position inASCII strings1of the first character ofs1not foundinASCII strings2, or0if all characters ofs1are found ins2plural(n,s)the plural ofsifn6= 1plural(n,s1,s2)the plural ofs1, as modified by or replaced withs2, ifn6= 1real(s)sconverted to numeric ormissingregexm(s,re)

2 Performs a match of a regular expression and evaluates to1if regularexpressionreis satisfied by theASCII strings; otherwise,0regexr(s1,re,s2)replaces the first substring withinASCII strings1that matchesrewithASCII strings2and returns the resulting stringregexs(n)subexpressionnfrom a previousregexm()match, where 0 n <10soundex(s)the soundex code for a String ,ssoundexnara(s)the Census soundex code for a String ,sstrcat(s1,s2)there is nostrcat()function; instead the addition operator is usedto concatenate stringsstrdup(s1,n)there is nostrdup()function.

3 Instead the multiplication operatoris used to create multiple copies of stringsstring(n)a synonym forstrofreal(n) String (n,s)a synonym forstrofreal(n,s)stritrim(s)swith multiple, consecutive internal blanks (ASCII space characterchar(32)) collapsed to one blankstrlen(s)the number of characters inASCIIsor length in bytesstrlower(s)lowercaseASCII characters in stringsstrltrim(s)swithout leading blanks (ASCII space characterchar(32))strmatch(s1,s2) 1ifs1matches the patterns2; otherwise,0strofreal(n)nconverted to a stringstrofreal(n,s)nconverted to a String using the specified display formatstrpos(s1,s2)the position ins1at whichs2is first found,0ifs2does not occur,and1ifs2is empty12 String functionsstrproper(s)a String with the firstASCII letter and any other letters immediatelyfollowing characters that are not letters capitalized.

4 All otherASCII letters converted to lowercasestrreverse(s)reverses theASCII stringsstrrpos(s1,s2)the position ins1at whichs2is last found,0ifs2does not occur,and1ifs2is emptystrrtrim(s)swithout trailing blanks (ASCII space characterchar(32))strtoname(s[,p])strans lated into a Stata 13 compatible namestrtrim(s)swithout leading and trailing blanks (ASCII space characterchar(32)); equivalent tostrltrim(strrtrim(s))strupper(s)upperc aseASCII characters in stringssubinstr(s1,s2,s3,n)s1, where the firstnoccurrences ins1ofs2have been replacedwiths3subinword(s1,s2,s3,n)s1, where the firstnoccurrences ins1ofs2as a word have beenreplaced withs3substr(s,n1,n2)the substring ofs, starting atn1, for a length ofn2tobytes(s[,n])escaped decimal or hex digit strings of up to 200 bytes ofsuchar(n)

5 The Unicode character corresponding to Unicode code pointnoran empty String ifnis beyond the Unicode code-point rangeudstrlen(s)the number of display columns needed to display the Unicode stringsin the Stata Results windowudsubstr(s,n1,n2)the Unicode substring ofs, starting at charactern1, forn2displaycolumnsuisdigit(s) 1if the first Unicode character insis a Unicode decimal digit;otherwise,0uisletter(s) 1if the first Unicode character insis a Unicode letter; otherwise,0ustrcompare(s1,s2[,loc])compa res two Unicode stringsustrcompareex(s1,s2,loc,st,case,c slv,norm,num,alt,fr)compares two Unicode stringsustrfix(s[,rep])replaces each invalidUTF-8sequence with a Unicode characterustrfrom(s,enc,mode)converts the stringsin encodingencto aUTF-8encoded Unicodestringustrinvalidcnt(s)the number of invalidUTF-8sequences insustrleft(s,n)the firstnUnicode characters of the Unicode stringsustrlen(s)the number of characters in the Unicode stringsustrlower(s[,loc])

6 Lowercase all characters of Unicode stringsunder the given localelocustrltrim(s)removes the leading Unicode whitespace characters and blanks fromthe Unicode stringsustrnormalize(s,norm)normalizes Unicode stringsto one of the five normalization formsspecified bynormustrpos(s1,s2[,n])the position ins1at whichs2is first found; otherwise,0ustrregexm(s,re[,noc])perform s a match of a regular expression and evaluates to1if regularexpressionreis satisfied by the Unicode strings; otherwise,0ustrregexra(s1,re,s2[,noc])re places all substrings within the Unicode strings1that matchrewiths2and returns the resulting stringString functions 3ustrregexrf(s1,re,s2[,noc])replaces the first substring within the Unicode strings1that matchesrewiths2and returns the resulting stringustrregexs(n)subexpressionnfrom a previousustrregexm()matchustrreverse(s)r everses the Unicode stringsustrright(s,n)the lastnUnicode characters of the Unicode stringsustrrpos(s1,s2[,n])the position ins1at whichs2is last found.

7 Otherwise,0ustrrtrim(s)remove trailing Unicode whitespace characters and blanks from theUnicode stringsustrsortkey(s[,loc])generates a null-terminated byte array that can be used by thesortcommand to produce the same order asustrcompare()ustrsortkeyex(s,loc,st,ca se,cslv,norm,num,alt,fr)generates a null-terminated byte array that can be used by thesortcommand to produce the same order asustrcompare()ustrtitle(s[,loc])a String with the first characters of Unicode words titlecased andother characters lowercasedustrto(s,enc,mode)converts the Unicode stringsinUTF-8encoding to a String inencodingencustrtohex(s[,n])escaped hex digit String ofsup to 200 Unicode charactersustrtoname(s[,p])stringstransl ated into a Stata nameustrtrim(s)removes leading and trailing Unicode whitespace characters andblanks from the Unicode stringsustrunescape(s)the Unicode String corresponding to the escaped sequences ofsustrupper(s[,loc])

8 Uppercase all characters in stringsunder the given localelocustrword(s,n[,loc])thenth Unicode word in the Unicode stringsustrwordcount(s[,loc])the number of nonempty Unicode words in the Unicode stringsusubinstr(s1,s2,s3,n)replaces the firstnoccurrences of the Unicode strings2with theUnicode strings3ins1usubstr(s,n1,n2)the Unicode substring ofs, starting atn1, for a length ofn2word(s,n)thenth word ins;missing("") ifnis missingwordbreaklocale(loc,type)the most closely related locale supported byICUfromlociftypeis1, the actual locale where the word-boundary analysis datacome from iftypeis2; or an empty String is returned for anyothertypewordcount(s)the number of words insFunctionsIn the display below,sindicates a String subexpression (a String literal, a String variable, or anotherstring expression) andnindicates a numeric subexpression (a number, a numeric variable, or anothernumeric expression).

9 If your strings contain Unicode characters or you are writing programs that will be used by otherswho might use Unicode strings, read[U] Handling Unicode String functionsabbrev(s,n)Description:names, abbreviated to a length ofnLength is measured in the number of display columns, not in the number ofcharacters. For most users, the number of display columns equals the number ofcharacters. For a detailed discussion of display columns, see[U] DisplayingUnicode any of the characters ofsare a period.

10 , andn <8, then the value ofndefaults to a value of 8. Otherwise, ifn <5, thenndefaults to a value of ,abbrev()will return the entire ()is typicallyused with variable names and variable names with factor-variable or time-seriesoperators (the period case).abbrev("displacement",8)isdispla~ :stringsDomainn:integers 5 to 32 Range:stringschar(n)Description:the character corresponding toASCIIor extendedASCII coden;""ifnis not inthe domainNote:ASCII codes are from 0 to 127; extendedASCII codes are from 128 to255.


Related search queries