In a survey dataset I have a string variable (type: str244) with qualitative responses. I want to count the number of characters in each response/string and generate a new variable containing this number.
Using the egenmore I have already counted the number of words using nwords, but I cannot find the counterpart for counting characters.
EXAMPLE:
egen countvar = nwords(stringvar)
where countvar is the new variable name and stringvar is the string variable.
Does such an egen function exist for counting characters?
wordcount()in Stata makes the older add-onnwords()redundant. Noteegenmoreis downloaded usingssc inst egenmore.egenmoredoes point towordcount(). N.B.nwords()(written for Stata 6) is very slow.gen countvar = wordcount(stringvar)works like a charm. I wasn't aware thatwordcountwas used withgen, notegen. Perfect!