data _null_;
input;
line = prxchange('s/\b*(\w+)\b*/A/', -1, _infile_);
count = count(line, 'A');
put count=;
cards;
this is a test
;
++++++++++++++++++++++++++++++++++++++++++++++++
Apparently, the method above is outdated.
With SAS 9.2, we can count the words in a string easilier.
The functions countw do the trick.
No comments:
Post a Comment