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

st: RE: how to prevent omission of zeroes in frequency tab


From   "Nick Cox" <[email protected]>
To   <[email protected]>
Subject   st: RE: how to prevent omission of zeroes in frequency tab
Date   Thu, 28 Jul 2005 18:28:01 +0100

The user-written program -tabcount- from SSC addresses
this problem. There was a discussion in 

Speaking Stata: Problems with tables, Part II. 
SJ 3(4): 420--439 (2003). 

Nick 
[email protected] 

A.M. Vos

> I have patient data, with one record for each patient, and about 100
> variables.
> I try to make many similar frequency tables of the variables ORIGIN,
> TOTDELKL, which should look like:
>                 TOTDELKL1  TOTDELKL2 TOTDELKL3 etc
> africa
> america
> europe
> 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
> tables.
> 
> 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 format?

*
*   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/



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