Date: Fri, 31 Aug 2007 13:29:33 -0000
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
Subject: Re: derive variables for dataset (urgent)
Content-Type: text/plain; charset="utf-8"
On Aug 31, 2:12Â am, RolandRB <rolandbe...@hotmail.com> wrote:
> On 31 Aug, 02:57, sas...@gmail.com wrote:
> > Dear all,
> > I am assigned to create a dataset and it has few variables that i need
> > to derive but i am not quite sure how i would do that. Any help would
> > really be appreciated.
> > Variable to be derived is x.
> > Procedure:
> > This is to be created for visits 1-6. If a subject has one record for
> > a value of visit set x=1 for that record.
> > If subject has multiple records for a value of visit, set x=1 for the
> > record where dayofstudy is closest to plannedday (see below).
> > If the assessments were performed the same distance from plannedday,
> > set x=1 for the record where dayofstudy > plannedday.
> > visit variable is derived using following information:
> > = -1 if .z < dayofstudy< -4
> > = 0 if -4 â‰¤ dayofstudy â‰¤ 0
> > = 1 if 1 â‰¤ dayofstudy â‰¤ 10
> > = 2 if 11 â‰¤ dayofstudy â‰¤ 17
> > = 3 if 18 â‰¤ dayofstudy â‰¤ 24
> > = 4 if 25 â‰¤ dayofstudy â‰¤ 34
> > = 5 if 35 â‰¤ dayofstudy â‰¤ 48
> > = 6 if 49 â‰¤dayofstudy â‰¤ 59
> > Plannedday is defined for each visit as follows:
> > visit=1: plannedday=7
> > visit=2: plannedday=14
> > visit=3: plannedday=21
> > visit=4: plannedday=28
> > visit=5: plannedday=42
> > visit=6: plannedday=56
> > The dayofstudy for a patient 101 looks something like this:
> > ptno Â dayofstudy
> > 101 Â Â Â Â -7
> > 101 Â Â Â Â -1
> > 101 Â Â Â Â 7
> > 101 Â Â Â Â 14
> > 101 Â Â Â Â 21
> > 101 Â Â Â Â 28.
> > Can someone tell me how should i derive the flag x as per the
> > specifications given above?
> > I would appreciate your help.
> > Regards,
> I have done this in the past and it is easy. Set up a variable (I'll
> call it "abs") that contains the absolute difference between the
> actual day and the planned day. Next sort into visit abs descending
> dayofstudy order. The first record in each visit group will be the one
> you want so set the flag for "if first.visit".- Hide quoted text -
> - Show quoted text -
I tried doing that but this is what is happening. The below example is
after sorting it as you said. However i dont want to flag the
first.visit record, i want to flag the second record because in the
situation where there are multiple records per visit, flag the record
Can you suggest how can i do that?
visit abs dayofstudy plannedday
1 -6 1 7
1 2 9 7