Date: Fri, 19 Nov 1999 12:42:43 -0600
Reply-To: "Lambert, Bob" <Bob_Lambert@AFCC.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: "Lambert, Bob" <Bob_Lambert@AFCC.COM>
Subject: Re: Simple problem - but urgent...
Content-Type: text/plain; charset=us-ascii
It looks like SAS-L is back-logged again so if somebody's already pointed
this out.... then sorry for the redundancy. Anyway, my example below sort
of implies that you have to have your data in a sas data set. This is not
true. The following one-step code produces the same results.
data squirrel;
input NUMVAR;
retain NEWVAR;
if NUMVAR then NEWVAR=NUMVAR;
lines;
5
10
.
.
15
14
.
12
run;
proc print data=squirrel;
run;
> -----Original Message-----
> From: Lambert, Bob
> Sent: Friday, November 19, 1999 10:49 AM
> To: SAS-L@LISTSERV.UGA.EDU
> Subject: Re: Simple problem - but urgent...
>
> Perhaps a minor point, but the "else newvar=newvar;" line is not
> needed because of the retain statement.
>
> e.g.:
>
> data squirrel;
> input NUMVAR;
> lines;
> 5
> 10
> .
> .
> 15
> 14
> .
> 12
> run;
>
> data mouse;
> set squirrel;
> retain NEWVAR;
> if NUMVAR then NEWVAR=NUMVAR;
> run;
>
> proc print data=mouse;
> run;
>
> -----Original Message-----
> From: diltilia@MY-DEJA.COM [SMTP:diltilia@MY-DEJA.COM]
> Sent: Friday, November 19, 1999 8:57 AM
> To: SAS-L@LISTSERV.UGA.EDU
> Subject: Re: Simple problem - but urgent...
>
> Drazen,
>
> Try this:
> data x;
> set x;
> retain newvar ;
> if numvar ne . then newvar=numvar;
> else newvar=newvar;
> run;
>
> OUTPUT:
> OBS NUMVAR NEWVAR
>
> 1 5 5
> 2 10 10
> 3 . 10
> 4 . 10
> 5 15 15
> 6 14 14
> 7 14
> 8 12 12
>
>
> In article <813iso$1d5$1@as102.tel.hr>,
> "Drazen Orescanin" <drazen.orescanin@kaptol.hr> wrote:
> > Dear friends
> >
> > I have a table like this:
> >
> > OBS NUMVAR
> > 1 5
> > 2 10
> > 3 .
> > 4 .
> > 5 15
> > 6 14
> > 7 .
> > 8 12
> >
> > I want to have a table like this:
> >
> > OBS NUMVAR
> > 1 5
> > 2 10
> > 3 10
> > 4 10
> > 5 15
> > 6 14
> > 7 14
> > 8 12
> >
> > In other words, I want to retain the value of NUMVAR only if NUMVAR
> is
> > missing. Is there any simple solution to this problem?
> >
> > Thanks
> >
> > Drazen from Croatia
> >
> > --
> > I'm in favor of love as long as it doesn't happen when football is on
> > television...
> >
> >
>
>
> Sent via Deja.com <http://www.deja.com/>
> Before you buy.
>
|