[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

From |
"Nick Cox" <n.j.cox@durham.ac.uk> |

To |
<statalist@hsphsun2.harvard.edu> |

Subject |
st: RE: Code help |

Date |
Tue, 12 Nov 2002 12:43:12 -0000 |

Chris.Fergusson@sth.nhs.uk > > I have a large dta file set up containg survival > information for > about 500,000 cancer patients in a ceratin area. I wish to > set up a dofile > which will produce tables of relative survival for certain groups of > patients. > > In total I want to produce 72 seperate tables for > patients split > into groups of sex (males, females, both sexes combined), > diagnosis year > (diagnosed between 1981/1985, 1986/1990, 1991/1995) and age > at diagnosis > (aged between 14/44, 45/54, 55/64, 65/74, 75/84, 85/99, > 15/74, 15/99). > > Thus the first table I wish to produce will be for > males diagnosed > between 1981 and 1985 aged between 14 and 44. > Thus the second table I wish to produce will be for > males diagnosed > between 1981 and 1985 aged between 45 and 54. > ... > Thus the seventy first table I wish to produce will > be for both > sexes combined diagnosed between 1991 and 1995 aged between > 15 and 74. > Thus the seventy second table I wish to produce will > be for both > sexes combined diagnosed between 1991 and 1995 aged between > 15 and 99. > > I know it seems strange wanting to produce 72 tables > all at once but > I will be repeating this process over and over again for > different dta files > so a do-file is a must. > > I have the code in place to work through this as > detailed below with > one glorious omission. I am unsure where to include the command: > > use ***********.dta > > The do-file I have set up is below, and help or > advice would be most > appreciated. > > Christopher D Fergusson > > local c=1 > > while `c'<=3 { > > if `c'==1 { > qui keep if sex==1 > } > else if `c'==2 { > qui keep if sex==2 > } > else if `c'==3 { > qui drop if sex==3 > } > > local b=1 > > while `b'<=3 { > if `b'==1 { > qui keep if diagyr>=1981 > qui keep if diagyr<=1985 > } > else if `b'==2 { > qui keep if diagyr>=1986 > qui keep if diagyr<=1990 > } > else if `b'==3 { > qui keep if diagyr>=1991 > qui keep if diagyr<=1995 > } > > local a=1 > > while `a'<=8 { > > if `a'==1 { > qui keep if aadx>=14 > qui keep if aadx<=44 > } > else if `a'==2 { > qui keep if aadx>=45 > qui keep if aadx<=54 > } > else if `a'==3 { > qui keep if aadx>=55 > qui keep if aadx<=64 > } > else if `a'==4 { > qui keep if aadx>=65 > qui keep if aadx<=74 > } > else if `a'==5 { > qui keep if aadx>=75 > qui keep if aadx<=84 > } > else if `a'==6 { > qui keep if aadx>=85 > qui keep if aadx<=99 > } > else if `a'==7 { > qui keep if aadx>=15 > qui keep if aadx<=74 > } > else if `a'==8 { > qui keep if aadx>=15 > qui keep if aadx<=99 > } > > display "a is `a'; b is `b'; c is `c'" > > /*The following 4 lines produce the relative survival tables*/ > > stset ageexit, failure(status=1) origin(aadx) > sts list, at(0 1 2 3 4 5) > stset ageexit status, time0(aadx) > strel2, > br(0[.1]1[.25]3[.5]5[1]10)using(life8196.dta)mergeby(period > sex age)group(1) > continue > > local a=`a'+1 > > } > > local b=`b'+1 > > } > > > local c=`c'+1 > > } My experience is that doing it this way is going to be much more difficult to get right and to modify than something more simple-minded. There is a core of stuff you want to do which can be put in a program program def mytable version 7 syntax [if] stset ageexit `if', failure(status=1) origin(aadx) sts list `if', at(0 1 2 3 4 5) stset ageexit status `if', time0(aadx) ... end Note that the -if- condition supplied to -mytable- should be echoed to each command as appropriate. Then your do file can be a series of calls to -mytable- ================================== mydo.do * `1' will be the dta file specified use `"`1'"' mytable if sex == 1 & inrange(aadx,14,44) & inrange(diagyr,1981,1985) ... mytable if inrange(aadx,15,99) & inrange(diagyr,1991,1995) ================================== and at the command line you type do mydo "whatever.dta" Nick n.j.cox@durham.ac.uk * * 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/

**Follow-Ups**:**st: Re: Monte Carlo Simulation with a binomial probability***From:*Murray Finkelstein <murray.finkelstein@utoronto.ca>

**References**:**st: Code help***From:*Chris.Fergusson@sth.nhs.uk

- Prev by Date:
**RE: st: RE: NPTREND problem** - Next by Date:
**st: Mixed effects or GEE?** - Previous by thread:
**st: Code help** - Next by thread:
**st: Re: Monte Carlo Simulation with a binomial probability** - Index(es):

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