From: Al on
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
> 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
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
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;