## countc

Solved
Frequent Contributor
Posts: 81

# countc

Hi All,

Why does this program returns the value as 2 instead of 3????????

data _null_;

string = 'Baboons Eat Bananas ';

howmany = countc (string, "oo");

put howmany;

run;

Thnx

-Anand

Accepted Solutions
Solution
‎07-22-2013 03:37 AM
Frequent Contributor
Posts: 81

## Re: countc

i got that...it counts the all characters saperately mentioned in parentheses so it gives liberty to put randomly chars.

All Replies
Esteemed Advisor
Posts: 5,519

## Re: countc

Posted in reply to AnandSahu

Because there are two characters in string that are also in character list "oo". I don't understand why you expect 3. - PG

PG
Solution
‎07-22-2013 03:37 AM
Frequent Contributor
Posts: 81

## Re: countc

i got that...it counts the all characters saperately mentioned in parentheses so it gives liberty to put randomly chars.

Frequent Contributor
Posts: 120

## Re: countc

Posted in reply to AnandSahu

Hi,

COUNTC : counts individual character in a string.

Means countc tells that how many times given character is in string.

Data _null_;

string='ABCDEFGHIJKLMNOPQRSTUVWXYZ';

how_many=countc(string,'A');              *answer is 1

how_many1=countc(string,'AB);           *answer is 2

how_many2=countc(string,'AS')            * answer is 2

Put how_many : how_many1 : how_many2;

run;

Frequent Contributor
Posts: 81

## Re: countc

Posted in reply to umashankersaini

Thank you so much Umashankersaini

🔒 This topic is solved and locked.

Need further help from the community? Please ask a new question.

Discussion stats
• 4 replies
• 287 views
• 0 likes
• 3 in conversation