Date: Mon, 26 Oct 2009 23:51:21 -0700
Reply-To: gupt <pvsgupta@GMAIL.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: gupt <pvsgupta@GMAIL.COM>
Organization: http://groups.google.com
Subject: Re: how to get first obs from datasets sorted by two variables?
Content-Type: text/plain; charset=ISO-8859-1
On Oct 26, 9:35 pm, muthia.kachira...@GMAIL.COM (Muthia Kachirayan)
wrote:
> Try
>
> data sub_d1;
> set d1;
> BY ID;
> if first.id=1 and ... /* what should i do here*/
>
> On Mon, Oct 26, 2009 at 12:17 PM, Jeff <zhuj...@gmail.com> wrote:
> > I have a dataset d1:
> > id x y z w
> > 1 1 3 4 6
> > 1 4 8 9 0
> > 2 22 44 44 8
> > 2 23 34 45 8
> > 2 12 3 4 7
> > ;
>
> > which is sorted by two variables id and x in ascending order.
> > I want to get the first obs after sorting,
> > which is:
> > id x y z w
> > 1 1 3 4 6
> > 2 12 3 4 7
>
> > I tried
> > proc sort data=d1;
> > by id x;
> > run;
>
> > data sub_d1;
> > set d1;
> > if first.id=1 and ... /* what should i do here*/
>
> > Thanks,
> > Jeff
Hi, Jeff,
Your question is not clear, on what basis you are choosing the
observations.
|