Pages

Saturday, July 27, 2013

Widgets

What is the difference between Count, Count C and Count W?

Let us see with example a difference between Count, Count C and Count W in SAS:


DATA ds;
text = 'we are learning SAS function like booom boom';

noofwrd = COUNTW(text);
noofstr = COUNT(text,'boo');
noofchar = COUNTC(text,'bo');
RUN;

/* Result explanation */;

COUNTW
------
noofwrd = 8, because there are 8 words found in the string 'we are learning SAS function like booom boom'. So COUNTW
counts word in a string.

COUNT
-----
noofstr = 2, because there are 2 'boo' found in the string 'we are learning SAS function like booom boom'. So COUNT counts
how many times specific character/s is/are occured in a string.

COUNTC
------
noofchar = 8, because there are 2 'b' and 6 'o' (2+6=8) found in the string 'we are learning SAS function like booom boom'. So
COUNTC counts how many time specified character/s is/are occurred in a string. Difference of COUNTC with COUNT function is that COUNTC would look for 'b' and 'o' anywhere in the string and it does not need to be 'bo' in the string to be counted.

No comments:

Post a Comment