Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
RE: Re: st: RE: Patient age at first cancer exam in STATA
From
Joe Canner <[email protected]>
To
"[email protected]" <[email protected]>
Subject
RE: Re: st: RE: Patient age at first cancer exam in STATA
Date
Sun, 12 Jan 2014 03:48:18 +0000
Actually, I'm sure there are cancer patients in there, but Cancer==0 because the first record for each patient is a 0. You can solve this in one of two ways:
1. Create a variable (before the collapse) that indicates if the patient had any records with Cancer==1
bysort Patid: egen anyCancer=max(Cancer)
(Come to think of it that count variable we created before can also help; it's a cancer patient if the count is greater than 0)
2.Sort the records by Patid and Cancer and take the last one instead of the first one.
bysort Patid (Cancer): keep if _n==_N
________________________________________
From: [email protected] [[email protected]] on behalf of [email protected] [[email protected]]
Sent: Saturday, January 11, 2014 10:03 PM
To: [email protected]
Subject: Re: Re: st: RE: Patient age at first cancer exam in STATA
Dear Joe,
I have tried both: bysort Patid: keep if _n==1 and collapse.
Unfortunately none of them did work. It only kept 377 unique Patid,
neither of them was a cancer patient.
KR
John
*
* For searches and help try:
* http://www.stata.com/help.cgi?search
* http://www.stata.com/support/faqs/resources/statalist-faq/
* http://www.ats.ucla.edu/stat/stata/
*
* For searches and help try:
* http://www.stata.com/help.cgi?search
* http://www.stata.com/support/faqs/resources/statalist-faq/
* http://www.ats.ucla.edu/stat/stata/