sort ID PERIOD POFFSET
gen MARK=1 if (ID = ID[-1]) and (PERIOD=PERIOD[-1]) then MARK = 0
This is a great approach. I just want to add something. According to my understanding, this would make MARK=1 for the records with the smallest number of one set of ID and PERIOD. But it does not necessarily mean that the record with MARK=1 would be closest the expected date.
In this example,
Each period I select (M3, M6, M12...) I give an allowance of + &- 10
days.
(e.g. for M3=90 days from the day of enrollment, I select between day 80 and day 100). This is because patients did not always respect their appointment dates.
for some reasons, if the patient came at 81 and 93 days, PERIOD would be -9 and 3 respectively and the record with PERIOD=-9 would be selected (MARK=1) which is not desirable. To avoid this situation, we just need to neutralize the minus sign of POFFSET by doing this before sorting ID PERIOD POFFSET. So, I would suggest the following command:
if POFFSET<0 then POFFSET= -1*POFFSET[_n]
sort ID PERIOD POFFSET gen MARK=1 if (ID = ID[-1]) and (PERIOD=PERIOD[-1]) then MARK = 0
Best wishes, Zaw
Message: 5 Date: Mon, 27 Aug 2012 08:23:24 -0400 From: epidata-list@lists.umanitoba.ca Subject: Re: [EpiData-list] Epidata analysis To: epidata-list@lists.umanitoba.ca Message-ID: BLU0-SMTP250E7B96809BAD9A83BDABFDA20@phx.gbl Content-Type: text/plain; charset="windows-1252"
The approach to this would be:
- create the new variable that identifies period (I'm not sure why you use
more than one) (PERIOD)
- create a new variable that equals the number of days between expected
and actual visit (POFFSET)
- SORT the data on patient ID, PERIOD and POFFSET
- create a new variable to mark the first record you find for a given
patient and period (MARK) You do the last two steps like this:
sort ID PERIOD POFFSET gen MARK=1 if (ID = ID[-1]) and (PERIOD=PERIOD[-1]) then MARK = 0
MARK will set to zero for the second visit for any patient in a period (because ID and PERIOD will be the same as previous)
Jamie
On 2012-08-27, at 3:11 AM, epidata-list@lists.umanitoba.ca wrote:
I have a “.rec” Epidata data set with patients with chronic diseases (Diabetes and Hypertension). I would like to undertake some analysis to determine what is happening on the patients at different periods of
follow
up. (Month 3, 6, 12........)
i.e. Glucose levels, BP, BMI.......
Each period I select (M3, M6, M12...) I give an allowance of + &- 10
days.
(e.g. for M3=90 days from the day of enrollment, I select between day 80 and day 100). This is because patients did not always respect their appointment dates.
In the period selected (between day 80 -100) some patients for several reasons were seen more than once. I would like to select only one visit date in case of moth 3 follow up that is closest to the 90th day from
date
of enrollment .(e.g. a patient had a visit on the 80th day and 95th day,
I
want to select the 95th day visit which is closest to day 90).....
How do I do this with Epidata analysis?
NB: My variables are “enrolment date” and “visit date”
Kwal _______________________________________________ EpiData-list mailing list EpiData-list@lists.umanitoba.ca http://lists.umanitoba.ca/mailman/listinfo/epidata-list
EpiData-list@lists.umanitoba.ca http://lists.umanitoba.ca/mailman/listinfo/epidata-list
End of EpiData-list Digest, Vol 106, Issue 17
Right - you could also define POFFSET as
gen i POFFSET = abs(.....)
or
if POFFSET<0 then POFFSET= -1*POFFSET // no need for [_n]
Jamie
On 2012-08-27, at 5:47 PM, epidata-list@lists.umanitoba.ca wrote:
sort ID PERIOD POFFSET
gen MARK=1 if (ID = ID[-1]) and (PERIOD=PERIOD[-1]) then MARK = 0
This is a great approach. I just want to add something. According to my understanding, this would make MARK=1 for the records with the smallest number of one set of ID and PERIOD. But it does not necessarily mean that the record with MARK=1 would be closest the expected date.
participants (1)
-
epidata-list@lists.umanitoba.ca