| Functions and CALL Routines | 
| Category: | Character | 
| Restriction: | I18N Level 1 | 
| Syntax | |
| Arguments | |
| Details | |
| Comparisons | |
| Examples | |
| See Also | 
Syntax | 
| COUNTC(string, charlist <,modifiers>) | 
specifies a character constant, variable, or expression in which characters are counted.
| Tip: | Enclose a literal string of characters in quotation marks. | 
specifies a character constant, variable, or expression that initializes a list of characters. COUNTC counts characters in this list, provided that you do not specify the V modifier in the modifier argument. If you specify the V modifier, then all characters that are not in this list are counted. You can add more characters to the list by using other modifiers.
| Tip: | Enclose a literal string of characters in quotation marks. | 
| Tip: | If there are no characters in the list after processing the modifiers, COUNTC returns 0. | 
specifies a character constant, variable, or expression in which each non-blank character modifies the action of the COUNTC function. Blanks are ignored. The following characters, in uppercase or lowercase, can be used as modifiers:
| Tip: | If modifier is a constant, enclose it in quotation marks. Specify multiple constants in a single set of quotation marks. | 
| Details | 
The COUNTC function allows character arguments to be null. Null arguments are treated as character strings with a length of zero. If there are no characters in the list of characters to be counted, COUNTC returns zero.
| Comparisons | 
The COUNTC function counts individual characters in a character string, whereas the COUNT function counts substrings of characters in a character string.
| Examples | 
The following example uses the COUNTC function with and without modifiers to count the number of characters in a string.
data test; string = 'Baboons Eat Bananas '; a = countc(string, 'a'); b = countc(string,'b'); b_i = countc(string,'b','i'); abc_i = countc(string,'abc','i'); /* Scan string for characters that are not "a", "b", */ /* and "c", ignore case, (and include blanks). */ abc_iv = countc(string,'abc','iv'); /* Scan string for characters that are not "a", "b", */ /* and "c", ignore case, and trim trailing blanks. */ abc_ivt = countc(string,'abc','ivt'); run; options pageno=1 ls=80 nodate; proc print data=test noobs; run;
Output from Using the COUNTC Functions with and without Modifiers
                                 The SAS System                                1
             string           a    b    b_i    abc_i    abc_iv    abc_ivt
       Baboons Eat Bananas    5    1     3       8        16         11  
| See Also | 
| 
 | 
Copyright © 2011 by SAS Institute Inc., Cary, NC, USA. All rights reserved.