| Functions and CALL Routines |
| Category: | Character |
| Syntax | |
| Arguments | |
| Details | |
| Comparisons | |
| Examples | |
| See Also |
Syntax |
| COUNT(string,substring<,modifiers>) |
specifies a character constant, variable, or expression in which substrings are to be counted.
| Tip: | Enclose a literal string of characters in quotation marks. |
is a character constant, variable, or expression that specifies the substring of characters to count in string.
| Tip: | Enclose a literal string of characters in quotation marks. |
is a character constant, variable, or expression that specifies one or more modifiers. The following modifiers can be in uppercase or lowercase:
| i |
ignores character case during the count. If this modifier is not specified, COUNT only counts character substrings with the same case as the characters in substring. |
| t |
trims trailing blanks from string and substring. |
| Tip: | If the modifier is a constant, enclose it in quotation marks. Specify multiple constants in a single set of quotation marks. Modifier can also be expressed as a variable or an expression that evaluates to one or more constants. |
| Details |
The COUNT function searches string, from left to right, for the number of occurrences of the specified substring, and returns that number of occurrences. If the substring is not found in string, COUNT returns a value of 0.
For
example, COUNT('boobooboo', 'booboo') might return either a 1 or a 2. ![[cautionend]](../common.hlp/images/cautend.gif)
| Comparisons |
The COUNT function counts substrings of characters in a character string, whereas the COUNTC function counts individual characters in a character string.
| Examples |
The following SAS statements produce these results:
| See Also |
|
Functions: |
Copyright © 2007 by SAS Institute Inc., Cary, NC, USA. All rights reserved.