From: Joe Matise on 4 Oct 2009 23:43 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(a)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.. >
From: "Data _null_;" on 4 Oct 2009 23:45 data test; input Date:mmddyy. VarA; locf = coalesce(vara,locf); retain locf; cards; 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 . ;;;; run; proc print; run; On 10/4/09, Randy <randistan69(a)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.. >
From: Randy on 5 Oct 2009 00:19 Dear Joe: Slight variation of the problem: Date ID VarA 06/01/09 1 1402 06/01/09 1 . 06/01/09 1 . 06/02/09 1 1543 06/02/09 1 . 06/01/09 2 1602 06/01/09 2 . 06/01/09 2 . 06/02/09 2 1755 06/02/09 2 . The data set should look like this Date ID VarA 06/01/09 1 1402 06/01/09 1 1402 06/01/09 1 1402 06/02/09 1 1543 06/02/09 1 1543 06/01/09 2 1602 06/01/09 2 1602 06/01/09 2 1602 06/02/09 2 1755 06/02/09 2 1755 Thank You On Sun, 4 Oct 2009 22:45:42 -0500, Data _null_; <iebupdte(a)GMAIL.COM> wrote: >data test; > input Date:mmddyy. VarA; > locf = coalesce(vara,locf); > retain locf; > cards; >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 . >;;;; > run; >proc print; > run; > >On 10/4/09, Randy <randistan69(a)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.. >> Dear Joe: Slight variation to the problem: Date ID VarA 0
From: Joe Matise on 5 Oct 2009 00:20 So throw in ID in your by and first statements... -Joe On Sun, Oct 4, 2009 at 11:19 PM, Randy <randistan69(a)hotmail.com> wrote: > Dear Joe: > Slight variation of the problem: > > Date ID VarA > 06/01/09 1 1402 > 06/01/09 1 . > 06/01/09 1 . > 06/02/09 1 1543 > 06/02/09 1 . > 06/01/09 2 1602 > 06/01/09 2 . > 06/01/09 2 . > 06/02/09 2 1755 > 06/02/09 2 . > > The data set should look like this > Date ID VarA > 06/01/09 1 1402 > 06/01/09 1 1402 > 06/01/09 1 1402 > 06/02/09 1 1543 > 06/02/09 1 1543 > 06/01/09 2 1602 > 06/01/09 2 1602 > 06/01/09 2 1602 > 06/02/09 2 1755 > 06/02/09 2 1755 > > Thank You > > > > On Sun, 4 Oct 2009 22:45:42 -0500, Data _null_; <iebupdte(a)GMAIL.COM> > wrote: > > >data test; > > input Date:mmddyy. VarA; > > locf = coalesce(vara,locf); > > retain locf; > > cards; > >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 . > >;;;; > > run; > >proc print; > > run; > > > >On 10/4/09, Randy <randistan69(a)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.. > >> > > Dear Joe: > Slight variation to the problem: > > Date ID VarA > 0 >
From: Randy on 5 Oct 2009 00:24
Do not follow.. |