Date: Tue, 18 Nov 2008 21:01:16 -0800
Reply-To: xlr82sas <xlr82sas@AOL.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: xlr82sas <xlr82sas@AOL.COM>
Organization: http://groups.google.com
Subject: Re: data manipulation
Content-Type: text/plain; charset=ISO-8859-1
On Nov 18, 3:19 pm, Mterje...@RUSSELL.COM ("Terjeson, Mark") wrote:
> Hi,
>
> Here is one approach using RETAIN,
> which will keep a value across rows:
>
> data sample;
> infile cards missover;
> input Var $ Set;
> cards;
> a 1
> b
> c
> d 2
> e
> f
> g
> h 3
> i
> ;
> run;
>
> data result(drop=Hold_Set);
> set sample;
> retain Hold_Set .;
> if Set ne . then Hold_Set = Set;
> Set = Hold_Set;
> run;
>
> Hope this is helpful.
>
> Mark Terjeson
> Senior Programmer Analyst
> Investment Management & Research
> Russell Investments
> 253-439-2367
>
> Russell
> Global Leaders in Multi-Manager Investing
>
>
>
> -----Original Message-----
> From: SAS(r) Discussion [mailto:SA...@LISTSERV.UGA.EDU] On Behalf Of hd
> Sent: Tuesday, November 18, 2008 3:10 PM
> To: SA...@LISTSERV.UGA.EDU
> Subject: data manipulation
>
> Hello,
>
> My question is if I have a data set that looks like this
>
> Var Set
> a 1
> b
> c
> d 2
> e
> f
> g
> h 3
> i
>
> and I would like it to like this
>
> Var Set
> a 1
> b 1
> c 1
> d 2
> e 2
> f 2
> g 2
> h 3
> i 3
>
> In other words I want to just duplicate the entries until I reach an
> entry in the Set column and then want to duplicate that. I am not sure
> how I can do this, any help will be greatly appreciated.
>
> Thank you!- Hide quoted text -
>
> - Show quoted text -
One less line of code (untested)
data lvf(drop=set rename=lvf=set);
retain lvf;
set have;
if not missing(set) then lvf=set;
run;
|