Help using Base SAS procedures

how to count the frequency of a letter in a string

Reply
Regular Contributor
Posts: 222

how to count the frequency of a letter in a string


Hello everyone,

I want to count how many specified letter in a string,

such as:

%let have=123#45#678#9; we need to count how many '#' in the string.

in this case there are total three '#' in the string.

Thanks

data one;

a="123#45#678#9";

b=somefunction(a,'#');

run;

Respected Advisor
Posts: 3,156

Re: how to count the frequency of a letter in a string

Posted in reply to Mike_Davis

How about countc()?

data one;

a="123#45#678#9";

b=countc(a,'#');

put b=;

run;

Regular Contributor
Posts: 222

Re: how to count the frequency of a letter in a string

Posted in reply to Mike_Davis

data one;

a="123#45#678#9";

b=count(a,'#');

run;

Ask a Question
Discussion stats
  • 2 replies
  • 193 views
  • 3 likes
  • 2 in conversation