|Date: ||Thu, 16 Feb 2006 15:27:33 -0500|
|Sender: ||"SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>|
|From: ||Nat Wooding <Nathaniel_Wooding@DOM.COM>|
|Subject: ||Re: Help with lag|
|Content-Type: ||text/plain; charset="US-ASCII"|
Here's a solution. Note that you do not need the retain in the first data
step and you will need to read the dates as SAS date values.
* retain visit;
input patient $10. visit $3. collection_date date11.;
format col: mmddyy10.;
format col: lastvisit mmddyy10.;
if lastvisit gt collection_date then flag='*';
Sent by: "SAS(r) SAS-L@LISTSERV.UGA.EDU
Help with lag
Please respond to
Here's a question that a colleague asked me and since I was
stumped, I decided to ask you folks.
input patient $10. visit $3. collection_date $11.;
If you observe, the third observation has a date of 09-FEB-2002 which is
earlier than the previous visit but the visit number is greater. I want
to put a flag on those observations (in this case the 3rd one) where the
date is earlier than the previous visit.
I tried the following but it puts a flag on all observations so any
input from you to correct the code would be really appreciated.
if visit>lag(visit) and collection_date<lag(collection_date)
CONFIDENTIALITY NOTICE: This electronic message contains
information which may be legally confidential and/or privileged and
does not in any case represent a firm ENERGY COMMODITY bid or offer
relating thereto which binds the sender without an additional
express written confirmation to that effect. The information is
intended solely for the individual or entity named above and access
by anyone else is unauthorized. If you are not the intended
recipient, any disclosure, copying, distribution, or use of the
contents of this information is prohibited and may be unlawful. If
you have received this electronic transmission in error, please
reply immediately to the sender that you have received the message
in error, and delete it. Thank you.