For this question, I cannot make sense the answer for wordnum. I think it should be 3. Can you please help me to figure it out? Thanks so much
There are 4 words in the text string - 'US' counts as a word too. COUNTW counts words.
COUNTW without any modifiers and just the string will count everything separated by the default list of delimiters as a word. Since comma and space are some of the default delimiters when you do
Countw('Australia, Italy, Austria, US') then the first word is Australia, second is Italy, third is Austria and 4th is US.
In this code:
data example;
x ='123,ABC, six, B, Pdq, {, #';
count = countw(x);
put count=;
run;
The result is 7 because anything delimited by comma and space counts as a "word" even the single characters { and # unless you modify the list of delimiters.
In this
data example;
x ='123,ABC, six, B, Pdq, {, #';
count = countw(x,'B');
put count=;
run;
the 'B' in the countw function modifies the list of delimiters and in this case will use only the letter B as a delimiter. So the "words" become : "123,A" "C, six, " and ", Pdq, {, #".
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
Still thinking about your presentation idea? The submission deadline has been extended to Friday, Nov. 14, at 11:59 p.m. ET.
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.