Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.

# Re: st: Descriptive statistics - counting aspects of a variable

 From Ronnie Babigumira To statalist@hsphsun2.harvard.edu Subject Re: st: Descriptive statistics - counting aspects of a variable Date Sun, 3 Jun 2012 17:23:00 +0200

```You ask .....how do I find out how many have a diagnoses with numbers in combination with letters (like 618A)...

Are you looking for a simple count? If yes, -count- as you have done is one way of doing it but you could also use -tab- and many other -tab- relatives on ssc.

Always nice to show some data (an easy way to do this is to advantage of the very useful -writeinput- on ssc. To install, type -ssc install writeinput-)

// create a demo dataset
clear
set seed 000111
set obs 20
gen id = _n
gen xxt = uniform()
g xx = cond(xxt < .3, "680H", cond(xxt < .6, "720H", cond(xxt < 1,"616","")))

list

// How many have 616
count if xx == "616"

// See how many had the different diagnoses
tab xx

--
010100100110111101101110011011100110100101100101

On Sunday, June 3, 2012 at 4:24 PM, Amal Khanolkar wrote:

> Hello all,
>
> I have a variable XX that describes various diagnoses that my subjects might have. Diagnoses are coded using the usual ICD 8-10 codes. While most diagnoses are just numerical, some end with an alphabet, for e.g. 618A or 720H.
>
> I can ask Stata to tell me how many subjects in my dataset have diagnoses 618 by:
>
> count if XX==616
>
> However how do I find out how many have a diagnoses with numbers in combination with letters (like 618A). Stata isn't able to tell me using the 'count' or 'sum' commands as above.
>
> Thanks,
>
> /Amal.
>
>
>
> *
> * For searches and help try:
> * http://www.stata.com/help.cgi?search
> * http://www.stata.com/support/statalist/faq
> * http://www.ats.ucla.edu/stat/stata/

*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/
```