Prev: Please help! ----SAS IML for Newton Iteration, Weibull distribution...
Next: SAS Enterprise Guide (EG) - Error when exporting data set to local pc
From: Al on 14 Apr 2010 23:57 All; I have this dataset patno visit vsdt 1 1 10OCT2009 1 2 14OCT2009 1 3 12OCT2009 2 1 11SEP2009 2 2 13SEP2009 2 3 14SEP2009 3 1 21MAY2009 3 2 22MAY2009 3 3 20MAY2009 3 4 23MAY2009 4 1 11JAN2009 4 2 12JAN2009 4 3 13JAN2009 i need to identify all the patno where the vsdt are less that the previous vsdt ... In the above case . patno , 1 and 3 Thanks Al
From: Eckhard Becker on 15 Apr 2010 02:21 > I have this dataset > i need to identify all the patno where the vsdt are less that the > previous vsdt ... Take a look for "retain" and/or lag. Be aware, that the lag-function is like a stack, not a pointer to previus obs. HTH -- Tschau, Eckhard http://www.ebecker.de
From: Al on 15 Apr 2010 10:35 On Apr 15, 1:21 am, Eckhard Becker <u...(a)eckhardb.de> wrote: > > I have this dataset > > i need to identify all the patno where the vsdt are less that the > > previous vsdt ... > > Take a look for "retain" and/or lag. > Be aware, that the lag-function is like a stack, not a pointer to > previus obs. > > HTH > -- > Tschau, > Eckhardhttp://www.ebecker.de Any thoughts on above datasetp question .. Thanks
From: Reeza on 15 Apr 2010 11:48
On Apr 15, 7:35 am, Al <ali6...(a)gmail.com> wrote: > On Apr 15, 1:21 am, Eckhard Becker <u...(a)eckhardb.de> wrote: > > > > I have this dataset > > > i need to identify all the patno where the vsdt are less that the > > > previous vsdt ... > > > Take a look for "retain" and/or lag. > > Be aware, that the lag-function is like a stack, not a pointer to > > previus obs. > > > HTH > > -- > > Tschau, > > Eckhardhttp://www.ebecker.de > > Any thoughts on above datasetp question .. Thanks Retain or lag function is required. Something like below should help you get started proc sort data=have; by patno visitdate; data want; set have; by patno; retain lastdate 0 flag=0; if first.subjid then do; last_date=visit_date; flag=0; end; else if visit_date<last_date then flag=1; if last.subjid and flag=1 then output patno; run; |