From: Al on
Dear All:


I have the folowing dataset

Patno Week1 Week2 week3 x
1 10/01/2008 10/11/2008 . 10/11/2008
2 10/02/2008 10/16/2008 10/24/2008 10/24/2008
3 10/03/2008 10/17/2008 . 10/17/2008
4 10/04/2008 . .
10/04/2008

I want to create a variable x with last know date for every patno
using arrays or any other data step method

Thanks in advance
Al


From: Chris Jones on
On 13 Apr, 05:41, Al <ali6...(a)gmail.com> wrote:
> Dear All:
>
> I have the folowing dataset
>
> Patno    Week1       Week2        week3                  x
> 1     10/01/2008   10/11/2008     .                       10/11/2008
> 2     10/02/2008   10/16/2008     10/24/2008        10/24/2008
> 3     10/03/2008   10/17/2008      .                      10/17/2008
> 4     10/04/2008        .                .
> 10/04/2008
>
> I want to create  a variable x with last know date for every patno
> using arrays or any other data step method
>
> Thanks in advance
> Al

Try something like this (takes into account multiple records of same
patno's)

data outdat ;
set indat ;
by patno ;

retain maxdate . ;

if first.patno then maxdate = . ;

maxdate = max(maxdate , max(of week:)) ;

if last.patno then do ;
x = maxdate ;
output ;
end ;
run ;