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

st: how to prevent omission of zeroes in tables II


From   "A.M. Vos" <[email protected]>
To   [email protected]
Subject   st: how to prevent omission of zeroes in tables II
Date   Thu, 28 Jul 2005 14:59:26 +0200

In addition to my previous question:
dataset contains individual patient data, on about 100 variables and 8000
patients.

if I let Stata carry out the following syntax,
>keep if (YOUNG==1 & TSI==1 & REDENOZ==1 & CLUSPL==0)
>table ORIGIN, c(mean TOTDELKL median TOTDELKL)
I will obtain a table which only contains those values for ORIGIN that are
present in the subset of my data specified by (YOUNG==1 & TSI==1 &
REDENOZ==1 & CLUSPL==0).
Of course, no means and medians can be calculated if there are no
observations, but I would prefer to see all 10 possible values of ORIGIN in
the table, with blanks in the columns for mean and median if there are no
observations, in order to make the tables for different subsets of data
comparable. Any suggestions?

In addition, I don't want to check wether a specific subset (specified by
the values for YOUNG, TSI, etc) is empty or not before I ask for these
tables, since there are 60 possible subsets and I'd like to simply copy and
paste syntax. But if I ask for a table of an empty subset of my data, this
results in an error. Can I avoid this?

thanks, Annelies

"A.M. Vos" wrote:

> Dear all,
> 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?
>
> 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:
> *   http://www.stata.com/support/faqs/res/findit.html
> *   http://www.stata.com/support/statalist/faq
> *   http://www.ats.ucla.edu/stat/stata/

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