Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: how to prevent omission of zeroes in frequency tab

From   "A.M. Vos" <[email protected]>
To   [email protected]
Subject   st: how to prevent omission of zeroes in frequency tab
Date   Thu, 28 Jul 2005 13:53:22 +0200

Dear all,
I have patient data, with one record for each patient, and about 100
I try to make many similar frequency tables of the variables ORIGIN,
TOTDELKL, which should look like:
                TOTDELKL1  TOTDELKL2 TOTDELKL3 etc

such tables have to be made for each possible combination of the values
of the variables (with possible values as specified) YOUNG (1,2),
TSI(1-5), REDENOZ(1,2), CLUSPL(0,1,2). Thus I should obtain 2*5*2*3=60

However, some of these tables will contain only zeroes, since no patient
has their combination of values. There may also be tables where a whole
row or a whole column contains zeroes, since no patient has the value
africa in the variable ORIGIN or no patient has the value 2 in the
variable TOTDELKL, etc.

here is a piece of my syntax:

> use "mydata.dta", clear
> keep if (YOUNG==1 & TSI==1 & REDENOZ==1 & CLUSPL==0)
> preserve
> contract ORIGIN TOTDELKL, zero
> reshape wide _freq, i(ORIGIN) j(TOTDELKL)

the problem is, that if the combination YOUNG==1 & TSI==1 & REDENOZ==1 &
CLUSPL==0 does not exist at all, this syntax results in a "dataset" with
all 100 original variables, but no observations (I prefer to get the
specified frequency table with only zeroes),

and more important, if the combination does exist, but there are no
observations for ORIGIN=africa, or no observations for TOTDELKL=1, than
I get a table where africa is omitted or TOTDELKL 1 is omitted. This
makes my 60 tables difficult to compare.
Is there a way to obtain empty tables / columns / rows in the specified

thanks, Annelies

A.M. Vos
dept. of Public Health
Erasmus MC
University Medical Center Rotterdam
P.O. Box 1738
3000 DR Rotterdam
The Netherlands
Tel: +31 (10) 4087502
Fax: +31 (10) 4089449
email: [email protected]

*   For searches and help try:

© Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index