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 (March 2009, week 4)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Mon, 23 Mar 2009 15:17:22 -0400
Reply-To:     Akshaya <akshaya.nathilvar@GMAIL.COM>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         Akshaya <akshaya.nathilvar@GMAIL.COM>
Subject:      Re: recalculate variables - retain?
Comments: To: Pete Miller <pbpbta@googlemail.com>
In-Reply-To:  <200903231826.n2NG05Gx017240@malibu.cc.uga.edu>
Content-Type: text/plain; charset=ISO-8859-1

Dropping cycleid from original datafile and recreating it will work. data have(drop=cycleid); input id cycle cycleid (sd ed) (:date9.); format sd ed date9.; cards; 1 1 1 1JUL2005 31JUL2005 1 2 1 1AUG2005 31AUG2005 1 3 1 15SEP2005 30SEP2005 1 3 2 1SEP2005 14SEP2005 1 4 1 1OCT2005 30OCT2005 1 5 1 1DEC2005 31DEC2005 1 6 1 1NOV2005 30NOV2005 ; run;

Proc sort; by id cycle sd; Run;

Data want; do until(last.cycle); set have; by id cycle sd; cycleid=sum(cycleid,1); output; end; Run;

On Mon, Mar 23, 2009 at 2:26 PM, Pete Miller <pbpbta@googlemail.com> wrote:

> Dear list members, > > i've got following problem with a dataset that looks like: > > data have; > input id cycle cycleid startdate enddate; > cards; > 1 1 1 1JUL2005 31JUL2005 > 1 2 1 1AUG2005 31AUG2005 > 1 3 1 15SEP2005 30SEP2005 > 1 3 2 1SEP2005 14SEP2005 > 1 4 1 1OCT2005 30OCT2005 > 1 5 1 1DEC2005 31DEC2005 > 1 6 1 1NOV2005 30NOV2005 > ; > run; > > My problem is, that for cycle= 3 the subcycles or cycleid's are correct, > bur they should be in order of the date variables. This should also be > done for the cycles 5 and 6; > > so that the dataset should look like: > data need; > input id cycle cycleid startdate enddate; > cards; > 1 1 1 1JUL2005 31JUL2005 > 1 2 1 1AUG2005 31AUG2005 > > 1 3 1 1SEP2005 14SEP2005 > 1 3 2 15SEP2005 30SEP2005 > > 1 4 1 1OCT2005 30OCT2005 > > 1 5 1 1NOV2005 30NOV2005 > 1 6 1 1DEC2005 31DEC2005 > ; > run; > > When using retain I must sort by cycle,to avoid the error, not sorted; > when sorting by date and then by cycle,i get no cycleid's. > > can someone show me a way how to do this? > > Thank you very much > > Pete >

-- AkshayA!


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