Date: Wed, 23 Dec 2009 11:14:51 +0100
Reply-To: Daniel Fernández <fdezdan@GMAIL.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Daniel Fernández <fdezdan@GMAIL.COM>
Subject: Re: data step
In-Reply-To: <B282BE35B5A4494894D4ECFBA2BF784715A26B712F@XCH-NW-17V.nw.nos.boeing.com>
Content-Type: text/plain; charset=ISO-8859-1
yes, when you point to 'automatic' first and last variables, the same
variables have to be called first at the BY statement.
So I guess you need to rewrite to:
BY DATE;
Daniel Fernández.
Barcelona
2009/12/22 Schwarz, Barry A <barry.a.schwarz@boeing.com>:
> You want first.id etc.
>
> -----Original Message-----
> From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] On Behalf Of William Shakespeare
> Sent: Tuesday, December 22, 2009 11:46 AM
> To: SAS-L@LISTSERV.UGA.EDU
> Subject: data step
>
> I have data that are sorted by customer number and transaction date. I
> want to flag the first and last transaction for each customer:
>
> proc sort data=sasdata.have;
> by id date;
> run;
>
> data sasdata.want;
> set sasdata.have;
> by id;
> if first.date then first_flag=1;else first_flag=0;
> if last.date then last_flag=1;else last_flag=0;
> run;
>
> SAS successfully executes the sort and then runs the data step with this
> note:
>
> NOTE: Variable first.date is uninitialized.
> NOTE: Variable last.date is uninitialized.
>
> These variables exist. What am I doing wrong?
>
|