Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.
From | Nick Cox <n.j.cox@durham.ac.uk> |
To | "'statalist@hsphsun2.harvard.edu'" <statalist@hsphsun2.harvard.edu> |
Subject | st: RE: Analysing patient's admission over time |
Date | Thu, 10 Nov 2011 08:48:45 +0000 |
Use technique such as bysort pseudoid quarter primary : gen admissions_primary = _N by pseudoid quarter : gen admissions_any_reason = _N l if primary == "560.9" & admissions_primary > 1 For a tutorial, see SJ-2-1 pr0004 . . . . . . . . . . Speaking Stata: How to move step by: step . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . N. J. Cox Q1/02 SJ 2(1):86--102 (no commands) explains the use of the by varlist : construct to tackle a variety of problems with group structure, ranging from simple calculations for each of several groups to more advanced manipulations that use the built-in _n and _N Nick n.j.cox@durham.ac.uk Dudekula, Anwar I am analyzing a data set containing de-identified patients with crohns disease or ulcerative colitis-UC admitted to the hospital over time . A part of the dataset admitted for is pasted below.( after removing the identifiers) It contains 1)patients pseudoid( distinct for each person)-String variable 2)Primary diagnosis crohns disease or ulcerative colitis)-numeric value(0/1) 3)age -Numeric value 4)Primary diagnosis (ICD9 code , string value) 5)Secondary diagnosis (ICD9code, string value) 6)admission over quarter of year( first-Q1;Second-Q2;third-Q3 and forth -Q4)-Numeric value(1,2,3,4) +------------------------------------------------------------------+ | pseudoid crohns UC age Primary Secondary quarter | diagnosis diagnosis |------------------------------------------------------------------| 1. | pseudoid1 Crohns No UC 57 560.9 555.9 Q4 | 2. | pseudoid2 Crohns No UC 32 555.0 560.9 Q4 | 3. | pseudoid3 No Crohns UC 83 584.9 276.2 Q1 | 4. | pseudoid1 No Crohns UC 78 578.9 285.1 Q4 | 5. | pseudoid2 No Crohns UC 63 038.9 584.9 Q2 | 6. | pseudoid3 Crohns No UC 60 555.1 285.1 Q2 | 7. | pseudoid4 No Crohns UC 60 V55.2 556.8 Q3 | 8. | pseudoid5 Crohns No UC 42 579.3 555.9 Q4 | 9. | pseudoid6 Crohns No UC 23 566 682.5 Q4 | 10. | pseudoid1 No Crohns UC 22 556.9 276.51 Q1 | +------------------------------------------------------------------+ Questions: 1)How do I identify patients( and their age, diagnosis , associated secondary diagnosis) who had repeated admissions( Eg more than one admission) over each quarter of the year 2)How can I subset those patients 3)Most common secondary diagnosis in patients with primary diagnosis of Crohns or ulcerative colitis * * For searches and help try: * http://www.stata.com/help.cgi?search * http://www.stata.com/support/statalist/faq * http://www.ats.ucla.edu/stat/stata/