Date: Tue, 16 Mar 2004 11:55:55 -0800
Reply-To: Kristie K <kristie1273@YAHOO.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Kristie K <kristie1273@YAHOO.COM>
Subject: looking ahead question
Content-Type: text/plain; charset=us-ascii
Hi SAS-L,
I have read through the archives the various ways of looking ahead in a dataset and am currently employing the
proc sort descending by variable of interest;
and then
data step to lag that variable
in order to get not only looking ahead for the variable of interest but also other information I need from that line of data.
here is my actual code;
proc sort data=selfrpt out=du (keep=invno ptno visitno vday visitdt dayuse dayusec op); by patid visitno descending op; run;
data du (drop=prevop);
set du;
by patid visitno;
prevop=lag(opiates);
if first.patid then prevop=.;
if op=1 and prevop=3 then op=4;
if last.visitno;
run;
I was wondering if it was possible to use a different method to look forward in the dataset using a type of merge firstobs=2 even though patid is multiple lines of the same data and visitno is unique? And I would need these variables in the new dataset? I read about 4 methods of looking forward in the data but was hoping for some assistance on the merge firstobs=2 method.
Thanks in advance,
Kristie
Do you Yahoo!?
Yahoo! Mail - More reliable, more storage, less spam