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 (April 2011, week 1)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Thu, 7 Apr 2011 16:11:59 -0400
Reply-To:     "Mao, Viola (CONT)" <Viola.Mao@CAPITALONE.COM>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         "Mao, Viola (CONT)" <Viola.Mao@CAPITALONE.COM>
Subject:      Re: Counter SAS programming
In-Reply-To:  <BANLkTinf+kKgc3HjKfvybk7+PhHq1YnE+A@mail.gmail.com>
Content-Type: text/plain; charset="us-ascii"

I understand the codes are correct. But why is there no "retain" for _1_Y and _last_Y

Thanks

-----Original Message----- From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] On Behalf Of Yu Zhang Sent: Thursday, April 07, 2011 3:48 PM To: SAS-L@LISTSERV.UGA.EDU Subject: Re: Counter SAS programming

data want ; do until (last.id); set alldata; by id; if enroll='Y' and missing(_1_Y) then _1_Y=1; if enroll='N' and _1_Y then _last_Y =1;

if _1_Y and not _last_Y then output; end; run;

On Thu, Apr 7, 2011 at 2:36 PM, SUBSCRIBE SAS-L Anonymous < hari.sas.j@gmail.com> wrote:

> Thank You very much Dan and Zhang, > > I realised now that I should start counting(indexing) from the first > instance of enroll = Y and delete all subsequent records when I encounter > enroll = N and also, delete any enroll = N before I encounter first > instance of enroll = Y. > > Below is an example: > > data alldata; > input id month enroll $; > datalines; > 1 1 N > 1 2 Y > 1 3 Y > 1 4 Y > 1 5 N > 1 6 Y > 2 1 Y > 2 2 Y > 2 3 Y > 2 4 N > 2 5 N > 2 6 Y > ; > run; > > data is unique by id and month. > > The desired output is > > id month enroll index > 1 2 Y 1 > 1 3 Y 2 > 1 4 Y 3 > 2 1 Y 1 > 2 2 Y 2 > 2 3 Y 3 > > > Once again thanks for quick response. > > Regards >

The information contained in this e-mail is confidential and/or proprietary

to Capital One and/or its affiliates. The information transmitted herewith

is intended only for use by the individual or entity to which it is

addressed. If the reader of this message is not the intended recipient,

you are hereby notified that any review, retransmission, dissemination,

distribution, copying or other use of, or taking of any action in reliance

upon this information is strictly prohibited. If you have received this

communication in error, please contact the sender and delete the material

from your computer.


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