countc

Accepted Solution Solved
Reply
Frequent Contributor
Posts: 81
Accepted Solution

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.

View solution in original post


All Replies
Respected Advisor
Posts: 4,654

Re: countc

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: 116

Re: countc

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

Thank you so much Umashankersaini

☑ This topic is SOLVED.

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

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