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 (June 2008, week 1)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Mon, 2 Jun 2008 14:32:28 -0400
Reply-To:     "Howard Schreier <hs AT dc-sug DOT org>"
              <schreier.junk.mail@GMAIL.COM>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         "Howard Schreier <hs AT dc-sug DOT org>"
              <schreier.junk.mail@GMAIL.COM>
Subject:      Re: recode variable
Content-Type: text/plain; charset=ISO-8859-1

On Mon, 2 Jun 2008 14:05:14 -0400, Mike Zdeb <msz03@ALBANY.EDU> wrote:

>hi ... take advantage of the DOW (and the Paul Dorfman suggestion of using _N_ for loop >iteration, no need to DROP, no effect on counts of passes through the data step) ... > >data test; >input old : $2. @@; >datalines; >AA AA AA AD AE QQ QQ ZZ >; >run; > >* if test is sorted by OLD; > >data test; >need = _n_; >do _n_=1 by 1 until (last.old); > set test; > by old; > output; >end; >run;

A little simpler, I think:

data two; set test; by old; new + first.old; run;

> >-- >Mike Zdeb >U@Albany School of Public Health >One University Place >Rensselaer, New York 12144-3456 >P/518-402-6479 F/630-604-1475 > >> Hello! >> >> i'm looking for a solution for the following problem. >> i have a dataset with a variable OLD and want the variable NEED. >> >> >> old need >> AA 1 >> AA 1 >> AA 1 >> AD 2 >> AE 3 >> . . >> . . >> ZZ 100 >> >> my problem is that the number or variations of old can differ. >> >> Thank you >> >> Peter Müller >> >>


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