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 (August 2000, week 4)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:   Wed, 23 Aug 2000 15:19:47 EDT
Reply-To:   Bernard Tremblay <imaginasys@HOTMAIL.COM>
Sender:   "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:   Bernard Tremblay <imaginasys@HOTMAIL.COM>
Subject:   Re: newbie Retain question
Comments:   To: leamw@MY-DEJA.COM
Content-Type:   text/plain; charset=iso-8859-1; format=flowed

Hi,

Take off the "pat_num=1;" it resets the pat_number to 1 each loop...

try:

data two; set oneb; by pat_id; retain pat_num 0; if first.pat_id then pat_num+1; run;

The simpler, the better!

Regards, \\\|/// \\ - - // ( @ @ ) +-----oOOo-(_)-oOOo--+-----------------------------------+ | Bernard Tremblay | | | CSST | Tel: (418) 528-9313 | | | Fax: (418) 528-1493 | | | Int: Bernard.Tremblay@csst.qc.ca | +----------------------------+---------------------------+ | Imaginasys enr | Res: (418) 658-1411 | | | Int: bertrem@videotron.ca | | | Hot: imaginasys@hotmail.com | +--------------Oooo--+-----------------------------------+ oooO ( ) ( ) ) / \ ( (_/ \_) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ >From: leamw@MY-DEJA.COM >Reply-To: leamw@MY-DEJA.COM >To: SAS-L@LISTSERV.UGA.EDU >Subject: newbie Retain question >Date: Wed, 23 Aug 2000 18:53:59 GMT > >Hi: > >I know I'm doing something wrong here.. I just can't figure out what. > >I have a list of patient identifiers that are coded alphanumericallly. >I need them to be numeric. I thought that what I'd do is to just simply >number them from 1 to n using a retain and a sum statement like this: > >data two; >set oneb; >by pat_id; >pat_num=1; > >retain pat_num 1; > if first.pat_id then do; > pat_num=sum(pat_num,1); > end; >run; > >Of course all I get is the value of 2 for pat_num. >I have tried to replace the if statement with >things like: if pat_num ne 0 then do; >but this doesn't work either > >What am I doing wrong? > >Thanks > >Lea > > >Sent via Deja.com http://www.deja.com/ >Before you buy.

________________________________________________________________________ Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com


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