|
On Wed, 6 Jun 2007 16:30:47 -0000, BJMurphy <murphy.ben@GMAIL.COM> wrote:
>On Jun 5, 8:17 pm, datan...@GMAIL.COM ("data _null_;") wrote:
>> On 6/5/07, Schwarz, Barry A <barry.a.schw...@boeing.com> wrote:> Does not
a missing value always compare less than a non-missing one or
>> > does the min function make an exception for this?
>>
>> Yes, MIN function excludes missing values.
>>
>> > Isn't min set to 0 (1Jan1960) at the top of each data step iteration and
>> > will therefore be unchanged when any set of data has only later dates?
>>
>> No MIN is set to missing.
>>
>> I tested the program before I posted it.
>>
>>
>>
>>
>>
>> > -----Original Message-----
>> > From: data _null_; [mailto:snip]
>> > Sent: Tuesday, June 05, 2007 12:19 PM
>> > To: S...@LISTSERV.UGA.EDU
>> > Subject: Re: how to get min nonmissing date
>>
>> > Try to make your sample data a little more readable in future.
>>
>> > You don't really need any arrays. Just keep stashing the MIN.
>>
>> > data work.orig;
>> > input No (d1-d5) (:date7.);
>> > cards;
>> > 1 24mar07 22apr07 . 28jun06 .
>> > 1 . . 22jun06 24dec06 .
>> > 2 26apr06 25apr07 . 12jan06 26apr07
>> > ;;;;
>> > run;
>>
>> > data work.minDate;
>> > do until(last.no);
>> > set work.orig;
>> > by no;
>> > min = min(min,of d1-d5);
>> > end;
>> > format min date7.;
>> > drop d:;
>> > run;
>> > proc print;
>> > run;- Hide quoted text -
>>
>> - Show quoted text -
>
>Is there a way to use PROC SQL to do this, perhaps using the MIN()
>function over the array and using a GROUP BY over the ID? Would that
>work for the array?
>
>proc sql;
>select id,min(of d1-d5) from foo group by id;
>quit;
Something like that. Try
select no, min (min ( d1,d2,d3,d4,d5 ) ) as mindate format=date9.
from orig
group by no;
Result:
No mindate
-------------
1 22JUN2006
2 12JAN2006
|