Prev: Nobyline- table is splitting
Next: Driving Distances?
From: jiji on 5 Mar 2010 17:24 Hi, I have a longitidinal dataset with two surgeries (right and left). However I want to look at first surgery (event) which will be either right or left. the data looks something likes this: ID visit sxr sxl 1 1 0 0 1 2 0 1 1 3 1 0 1 4 0 0 2 1 0 0 2 2 0 1 2 3 1 0 3 1 1 0 3 2 0 1 3 3 0 0 How can I create a new variable that selects the first occurence of surgery either left or right for each subject. It may look like this: event 0 1 0 0 0 1 0 1 0 0 Thank you!!
From: Arthur Tabachneck on 6 Mar 2010 16:38 jiji, I think you are asking how to do something like the following: data want (drop=gotone); set have; by id; retain gotone; if first.id then gotone=0; event=0; if gotone eq 0 and sum(of sx:) gt 0 then do; event=1; gotone=1; end; run; HTH, Art ------------- On Mar 5, 5:24 pm, jiji <joelleahal...(a)gmail.com> wrote: > Hi, > > I have a longitidinal dataset with two surgeries (right and left). > However I want to look at first surgery (event) which will be either > right or left. > > the data looks something likes this: > > ID visit sxr sxl > 1 1 0 0 > 1 2 0 1 > 1 3 1 0 > 1 4 0 0 > 2 1 0 0 > 2 2 0 1 > 2 3 1 0 > 3 1 1 0 > 3 2 0 1 > 3 3 0 0 > > How can I create a new variable that selects the first occurence of > surgery either left or right for each subject. It may look like this: > > event > 0 > 1 > 0 > 0 > 0 > 1 > 0 > 1 > 0 > 0 > > Thank you!!
|
Pages: 1 Prev: Nobyline- table is splitting Next: Driving Distances? |