LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous messageNext messagePrevious in topicNext in topicPrevious by same authorNext by same authorPrevious page (March 2002, week 3)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Fri, 15 Mar 2002 10:50:02 +0100
Reply-To:     Jim Groeneveld <J.Groeneveld@ITGROUPS.COM>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         Jim Groeneveld <J.Groeneveld@ITGROUPS.COM>
Subject:      Re: "negative" LAG
Comments: To: Daniele Monzali <Daniele.Monzali@PROMETEIA.IT>
Content-Type: text/plain

Hi Daniela,

Yes, there is. Consider the following example:

DATA TestData; INPUT V1 @@; CARDS; 1 2 3 4 5 ; RUN;

DATA TestData; MERGE TestData TestData (FIRSTOBS=2 RENAME=(V1=V2)); * in current order, no BY; RUN;

PROC PRINT DATA=TestData; RUN;

Is it clear how it works or is some explanation necessary?

Regards - Jim. -- Y. (Jim) Groeneveld, MSc IMRO TRAMARKO tel. +31 412 407 070 senior statistician, P.O. Box 1 fax. +31 412 407 080 senior data manager 5350 AA BERGHEM IMRO TRAMARKO: a CRO J.Groeneveld@ITGroups.com the Netherlands in clinical research

My computer beeps when it complains; I complain when it beeps

Notice of confidentiality: this e-mail may contain confidential information intended for the addressed recipient only. If you have received this e-mail in error please delete this e-mail and please notify the sender so that proper delivery can be arranged.

> -----Original Message----- > From: Daniele Monzali [SMTP:Daniele.Monzali@PROMETEIA.IT] > Sent: Friday, March 15, 2002 10:26 AM > To: SAS-L@LISTSERV.UGA.EDU > Subject: "negative" LAG > > hello > i have the problem of adding to a SAS dataset a "negatively" lagged value > for a variabile, ie > > V1 V2 > 1 2 > 2 3 > 3 4 > 4 . > > my utterly inefficient solutions just consists in > > data out; > set in ; n=_n_; > run; > proc sort; by descending n; run; > data out; set out; v2=lag(v1); run; > proc sort; by n; run; > > cna anyone offer a more efficient solution ? > thanks a lot > daniele


Back to: Top of message | Previous page | Main SAS-L page