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 1)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Sun, 4 Oct 2009 22:43:45 -0500
Reply-To:     Joe Matise <snoopy369@GMAIL.COM>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         Joe Matise <snoopy369@GMAIL.COM>
Subject:      Re: Populating variables
Comments: To: Randy <randistan69@hotmail.com>
In-Reply-To:  <200910050336.n94AmYo9000335@malibu.cc.uga.edu>
Content-Type: text/plain; charset=ISO-8859-1

Several ways to do this; I'll post two.

Retain, and a simple datastep:

data want; set have; retain _VarA; if not missing(VarA) then _VarA = VarA; else VarA = _VarA; drop _varA; run;

If it's always on the first record for each date, then you can [and should] use it like: data want; set have; by date; retain _VarA; if first.Date then _VarA = VarA; else VarA = _VarA; drop _varA; run;

Now, another way, also assuming it's on the first record for each date:

data want; do _n_ = 1 by 1 until (last.date); set have; by date; if first.date then _varA = varA; end; varA = _varA; do _n_ = 1 by 1 until (last.date); set have(drop=varA); by date; output; end; drop _varA; run;

I am not at a SAS installation at the moment, so I can't test either of these for mistakes, but the theory should be correct.

-Joe

On Sun, Oct 4, 2009 at 10:36 PM, Randy <randistan69@hotmail.com> wrote:

> My data set is as follows > > Date VarA > 06/01/09 1402 > 06/01/09 . > 06/01/09 . > 06/02/09 1549 > 06/02/09 . > 06/03/09 2761 > 06/03/09 . > 06/03/09 . > 06/03/09 . > > It should look like > Date VarA > 06/01/09 1402 > 06/01/09 1402 > 06/01/09 1402 > 06/02/09 1549 > 06/02/09 1549 > 06/03/09 2761 > 06/03/09 2761 > 06/03/09 2761 > 06/03/09 2761 > > Can someone please help.. >


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