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 (November 2003, week 3)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:   Thu, 20 Nov 2003 06:26:58 -0800
Reply-To:   mindydiazh@YAHOO.COM
Sender:   "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:   mindydiazh@YAHOO.COM
Organization:   http://groups.google.com
Subject:   Re: data step problem
Content-Type:   text/plain; charset=ISO-8859-1

What I really mean is that "the last ele1 = 2 in case = 1" is "1 14626 2" observation, and "the last ele1 = 2 in case = 4" is "4 14522 2" observation. We cannot sort by ele1 to get the last ele1.

ghellrieg@T-ONLINE.DE (Gerhard Hellriegel) wrote in message news:<200311191809.hAJI97D30403@listserv.cc.uga.edu>... > 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


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