One basic idea is
gen count43480 = 0
qui foreach v of var dia2-dia13 {
replace count43480 = count43480 + (`v' == 43480)
}
but ultimately you will probably be better off with
a -reshape-
reshape long dia, i(id) j(which)
tab dia
See also -tabm- in -tab_chi- on SSC.
Nick
[email protected]
Jose Ignacio Pijoan Zubizarreta
> I have got a database with several secondary diagnoses
> dia2-dia13 coded
> according to the ICD9-CM code system (the icd9 commands work
> well in all of
> them). Some people have a given diagnosis ( e.g. 43840) as
> dia2 whereas
> other patients can have it included in dia3 or dia4 an so forth. Each
> individual can have only once a specific diagnostic code.
> What I would like
> to get is a new variable that counts the frequencies of every single
> diagnostic code across all patients and variables no matter in which
> position it does appear. This way I would be able to say that
> there are n
> different patients with a specific code ( e.g. 43840) out of the total
> sample.
*
* For searches and help try:
* http://www.stata.com/support/faqs/res/findit.html
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/