Date: Mon, 7 Aug 2006 17:13:14 +0000
Reply-To: toby dunn <tobydunn@HOTMAIL.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: toby dunn <tobydunn@HOTMAIL.COM>
Subject: Re: first none missing date
In-Reply-To: <54901f20608070940h515aff89vebd13a2be5631392@mail.gmail.com>
Content-Type: text/plain; format=flowed
Richard ,
Do you want hte first nonmissing date or do you want the earliest date that
isnt missing?
If it is the former your desired data set is wrong. If it is the later try:
Proc Sql ;
Create Table Need as
Select * , Min( Date ) As Start , Max( Date ) As End
From Test
Group By PatNo ;
Quit ;
Toby Dunn
Normal People Worry Me!!!!!
I reject your reality and substitute my own!!!
From: Richard Gong <gongcon@GMAIL.COM>
Reply-To: Richard Gong <gongcon@GMAIL.COM>
To: SAS-L@LISTSERV.UGA.EDU
Subject: first none missing date
Date: Mon, 7 Aug 2006 09:40:10 -0700
* Hi,
I have the following data set (test) and try to create two new variables
start_date and end_date. The start_date is the first none missing date and
the end date is the last none-missing date.
data* test;
input patno date date9.;
format date date9.;
datalines;
1 .
1 09JUL1994
1 05JUL1994
1 .
1 27JUL1994
run;
*The final result will be the following:*
patno date start_date end_date
1 . 05JUL1994 27JUL1994 1 09JUL1994 05JUL1994
27JUL1994
1 05JUL1994 05JUL1994 27JUL1994
1 . 05JUL1994 27JUL1994
1 27JUL1994 05JUL1994 27JUL1994
I tried to *sort* the data set first *by* patno and date and use retain and
*first.*patno to assign the value, but the problem is that I don't know how
to deal with the missing value.
Best Regards
gongcon