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

Re: st: count number of cases rather than observations


From   Eric Cahuzac <[email protected]>
To   [email protected]
Subject   Re: st: count number of cases rather than observations
Date   Fri, 25 Nov 2005 09:29:58 +0100

David,
try in two steps:

preserve
bysort id-number riskint: keep if _n==1
bysort riskint: count
restore

the count instruction give
------------------------------------
-> riskint = 0-9
   5
------------------------------------
-> riskint = 10-19
   2

not so pretty but working...
Eric


David Winter a �crit :

Hello,

I have some survival data and I want to identify the number of cases
that contribute person-time at risk. I also want to split the case by
age. I -stset- and -stsplit by age (entry to exit) and the by risk
interval:

stset var1 enter(time var2) fail(censor-var) id(id-number)
stsplit ageband at (.....)

stset var3 enter(time var4) fail(censor-var) id(id-number)
stsplit riskint at (....)

for 5 cases I might have the data split as follows:

id-number ageband riskint
--------- ------- -------
1 0-4 0-9
1 5-9 0-9
1 10-14 10-19
2 0-4 0-9
2 5-9 0-9
3 0-4 0-9
4 0-4 0-9
5 0-4 0-9
5 5-9 0-9
5 10-14 10-19

If I group by 'riskint' I would get the following result based on
observations

Riskint no of obs (contribute person-time at risk)
------- ---------
0-9 8
10-19 2

But what I want to identify and record is the no. of cases contributing
person-time at risk in each risk interval.

Riskint no of cases
------- -----------
0-9 5
10-19 2

There must be an easy way to do this?

Best wishes,
Dave
****************************************************
Mr David L. Winter, HNC
I.T. Manager (BCCSS Study)
Department of Public Health & Epidemiology
Room 105, Public Health Building
University of Birmingham
Edgbaston
Birmingham
B15 2TT
UK
tel.: +44 (0)121 414 6766
fax.: +44 (0)121 414 7923
****************************************************


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




--
______________________________

Eric Cahuzac
Institut National de la Recherche Agronomique (INRA)
Station d'Economie et Sociologie Rurale (ESR)
Chemin de Borde-Rouge - Auzeville
BP 52627, 31326 CASTANET-TOLOSAN CEDEX
Tel. 05.61.28.53.41 (direct)
    05.61.28.53.49 (secr�tariat)
Fax. 05.61.28.53.72
e-mail  [email protected]
http://www.toulouse.inra.fr/esr

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