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 (October 2009, week 3)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Fri, 16 Oct 2009 02:01:05 -0400
Reply-To:     Paul Dorfman <sashole@BELLSOUTH.NET>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         Paul Dorfman <sashole@BELLSOUTH.NET>
Subject:      Re: A Retain Statement OR Data manupulation question - If you can
              help me out it would be very nice
Comments: To: Tom Smith <need_sas_help@YAHOO.COM>

Tom,

Data step wise, this is a typical double-DoW application (input assumed sorted by subject cycle):

data want ; do _n_ = 1 by 1 until (last.cycle) ; set have ; by subject cycle ; if _n_ = 1 then _iorc_ = start ; end ; diff = end - _iorc_ ; do _n_ = 1 to _n_ ; set have ; output ; end ; run ;

Kind regards ------------ Paul Dorfman Jax, FL ------------

On Thu, 15 Oct 2009 19:55:21 -0400, Tom Smith <need_sas_help@YAHOO.COM> wrote:

>I have the following dataset with 4 variables (subject, >cycle, start, end) as below : > > >subject cycle start end >------- ----- ----- ---- >10001 1 5 >10001 1 6 >10002 2 8 >10002 2 10 >10003 1 7 >10004 1 8 > > >I need to calculate the new variable diff as ( end- start) by >the variables named subject & cycleand and >the final dataset should be as below (I am not sure but retain >statement might be needed): > > > > >subject cycle start end diff >------- ----- ----- --- ----- >10001 1 5 1 >10001 1 6 1 >10002 2 8 2 >10002 2 10 2 >10003 1 7 1 >10004 1 8 1 > > >Thank you from the bottom of my heart


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