Help using Base SAS procedures

counting symbols in a string

Reply
Frequent Contributor
Posts: 128

counting symbols in a string

how to count ", " in a string?

for example:
any function can return a number "2" when counting in the following string?

" one, two , three"= two commas.

Thanks a lot!
Valued Guide
Posts: 2,177

Re: counting symbols in a string

have you tried the count() function?
Super User
Posts: 10,028

Re: counting symbols in a string

try function : countc ();

[pre]
data _null_;
freq=countc(' one, two , three ' , ',');
put 'The count number of '','' is ' freq;
run;
[/pre]

Ksharp
Frequent Contributor
Posts: 128

Re: counting symbols in a string

Thanks, it works!
Ask a Question
Discussion stats
  • 3 replies
  • 118 views
  • 0 likes
  • 3 in conversation