The SAS Output Delivery System and reporting techniques

Count the keywords of the string

Accepted Solution Solved
Reply
Contributor
Posts: 46
Accepted Solution

Count the keywords of the string

Hello everbody!

Can I count the keywords of the string ?

Example :

%let colors = blue green yellow; ( I'd like to know if there is a function to return the number 3);

tk's in advanced !!

att

Gustavo Abud.


Accepted Solutions
Solution
‎06-14-2012 06:45 PM
Super Contributor
Posts: 1,636

Re: Count the keywords of the string

example:

data have;

string=' blue green yellow';

n=countw(string);

proc print;run;

View solution in original post


All Replies
Respected Advisor
Posts: 3,777

Re: Count the keywords of the string

Yes there is a function for that.

My question is why do you want to know?  Does it really matter?  Can you do what you want with the list of words without knowing how many there are?  I bet you can.

Solution
‎06-14-2012 06:45 PM
Super Contributor
Posts: 1,636

Re: Count the keywords of the string

example:

data have;

string=' blue green yellow';

n=countw(string);

proc print;run;

Contributor
Posts: 49

Re: Count the keywords of the string

%let n=%sysfunc(countw(&colors));

%put &n;

☑ This topic is solved.

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

Discussion stats
  • 3 replies
  • 230 views
  • 3 likes
  • 4 in conversation