Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Counting words in string variables?

1,215 views
Skip to first unread message

René Kopietz

unread,
Mar 6, 2006, 5:27:45 AM3/6/06
to
Hello,

in our latest study we used fill-in-the-blank open responses. We
imported them as string variables. Is there a way/function to count the
used words for a quantitative content analyses?

Thank you very much,
best Rene

Michael....@colostate.edu

unread,
Mar 6, 2006, 9:05:16 AM3/6/06
to

Here is a bit of syntax I had around to count white spaces,
except ones at the end of a string. With a it of modification,
I think this would work for your problem. Of course, it
counts all words, including articles, prepositions, etc.,
not just substantive words.


* Find and count white spaces in a target string, not counting
* ones at the end of the string .
* Essentially involves tokenizing a blank-delimited string .
string #blank (a1) .
compute #blank = ' '.
compute #strlen = length(rtrim(target)) .
compute k = 0 .
compute #i = 1 .
loop if (#i lt #strlen) .
* Find a white space .
loop .
compute #i = #i + 1 .
end loop if (substr(target,#i,1) eq #blank ) or
(#i = #strlen) .
* Skip past white space if not at end of string .
do if (#i lt #strlen).
compute k = k + 1 . /* count white space
loop if not (#i = #strlen) and /* skip pass current white space
(substr(target, #i,1) eq #blank) .
compute #i = #i + 1 .
end loop .
end if .
end loop .

--
=-=-=-=-=-=-=-=-=-==-=-=-=
Mike Lacy, Ft Collins CO 80523
Clean out the 'junk' to email me.

0 new messages