Date: Wed, 19 Nov 2003 13:09:07 -0500
Reply-To: Gerhard Hellriegel <ghellrieg@T-ONLINE.DE>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Gerhard Hellriegel <ghellrieg@T-ONLINE.DE>
Subject: Re: data step problem
Sorry, I think that is not understandable! What IS the "last ele1"? The
last in the group of case's? That cannot be the 1 14181 2 1 14077 which you
seem to have in your result dataset! So what is a "last ele1"? I'd say,
1 15630 0
seem to be a "last ele1" in the group of "case=1". The "pre-ele1" is 0, so
no output.
On Wed, 19 Nov 2003 08:46:29 -0800, mindydiazh@YAHOO.COM wrote:
>Hi,
>
>I sorted my data set by case and f1ad, but do not sort by ele1. In
>each case, every ele1 before the last ele1 = 2 must be 2. If not, I
>want to output to a data set TYPE1.
>data test1;
>infile cards4 missover;
>input case f1ad ele1;
>cards4;
>1 14077 1
>1 14181 2
>1 14297 1
>1 14398 .
>1 14516 2
>1 14578 2
>1 14626 2
>1 14864 1
>1 15053 0
>1 15327 0
>1 15460 0
>1 15620 0
>1 15630 0
>4 14116 .
>4 14200 2
>4 14305 2
>4 14431 2
>4 14522 2
>4 14613 .
>4 14816 1
>4 14998 0
>4 15180 0
>4 15439 0
>4 15691 0
>4 15895 0
>5 14139 2
>5 14314 2
>5 14496 0
>5 14699 0
>;;;;
>run;
>data type1;
> set test1;
> pre_ele1 = lag(ele1);
> pre_f1ad = lag(f1ad);
> if case = lag(case) and pre_ele1 ^= 2 and ele1 = 2 then do;
> if pre_f1ad ^= '.' then output;
> end;
>run;
>This is a output data set TYPE1 that I want to get.
>case f1ad ele1 pre_ele1 pre_f1ad
>1 14181 2 1 14077
>1 14398 . 1 14297
>1 14516 2 . 14398
>4 14200 2 . 14116
>
>Instead of this data set, I got one missing one observation.
>case f1ad ele1 pre_ele1 pre_f1ad
>1 14181 2 1 14077
>1 14516 2 . 14398
>4 14200 2 . 14116
>
>How do I fix my program? Thanks.
>
>Mindy
|