Date: Mon, 21 Mar 2005 12:35:46 -0500
Reply-To: "Howard Schreier <hs AT dc-sug DOT org>" <nospam@HOWLES.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: "Howard Schreier <hs AT dc-sug DOT org>" <nospam@HOWLES.COM>
Subject: Re: conditional data set creation
I agree totally with Art's suggestion that DATE be a numeric variable.
Then here's a one-step solution which preserves the existing order:
proc summary data=test;
by county notsorted;
output out=desired(drop = _type_ _freq_) min(date)=;
run;
Result:
Obs county date
1 orleans 22JAN2004
2 acadia 22FEB2004
3 caddo 10JAN2003
On Mon, 21 Mar 2005 08:27:54 -0500, Arthur Tabachneck <art297@NETSCAPE.NET>
wrote:
>Nevin,
>
>Here is yet another way to accomplish what you want but, before using any
>of the suggestions, change the way you input your initial file. Since you
>are entering date simply as a default length string, two problems occur.
>
>First, you are dropping the last two digits of each year. Second, since it
>is only a string, month (not the combination of month, day and year) will
>control the sort result.
>
>I'd recommend something like:
>
>data test;
> input county $ date mmddyy10.;
> format date date9.;
> cards;
>orleans 01/22/2004
>acadia 02/22/2004
>caddo 01/10/2003
>caddo 01/05/2004
>caddo 02/10/2004
>;
>run;
>proc sort data=test out=desired;
> by county date;
>run;
>proc sort data=desired nodupkey;
> by county;
>run;
>
>Art
>-------------
>On Sun, 20 Mar 2005 21:51:11 -0800, nevin <nevinkrishna@HOTMAIL.COM> wrote:
>
>>hello all,
>>
>>i have a dataset with counties and dates. and i am trying to create a
>>new dataset where which is comprised of the same variables except the
>>new dataset should contain the only one observation per county and this
>>observation should contain the earliest date for that county..below is
>>an example original dataset.
>>
>>
>>data test;
>> input county $ date $;
>>cards;
>>orleans 01/22/2004
>>acadia 02/22/2004
>>caddo 01/10/2004
>>caddo 01/05/2004
>>caddo 02/10/2004
>>;
>>run;
>>
>>what i would like the resulting new data set to look like is this:
>>
>>orleans 01/22/2004
>>acadia 02/22/2004
>>caddo 01/05/2004
|