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 (April 2003, week 3)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Tue, 15 Apr 2003 08:21:32 -0400
Reply-To:     Howard_Schreier@ITA.DOC.GOV
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         Howard_Schreier@ITA.DOC.GOV
Subject:      Re: Group continuous data ?

Try this:

data want; set have; by a; c + ( fuzz(dif(b))>1 ); if first.a then c = 1; run;

The expression contained by the outermost parentheses will have a value of one if B steps up by more than one, and a value of zero otherwise.

The FUZZ function is probably not needed, unless the values of B have been derived through some floating point arithmetic.

On Mon, 14 Apr 2003 13:09:38 -0700, Yang, Kai <Kai.Yang@CSHS.ORG> wrote:

>I want to group continuous data: >A B >1 3 >1 4 >1 5 >1 7 >1 8 >1 9 >1 10 >1 13 >1 14 >1 15 >2 2 >2 3 >2 4 >2 5 >2 6 >2 7 >2 15 >2 16 >2 17 >2 18 >2 19 >In A=1 part, the values of B variable are 3,4,5,7,8,910,13,14,15. Because >3,4,5 are continuous data, so, they are in same group (C=1). Same thing in >7,8,910 as second group (C=2), the rest of data in third group (C=3). >In A=2 part, it should be grouped in two groups (C=1 and C=2). >The final results should be looks like: >A B C >1 3 1 >1 4 1 >1 5 1 >1 7 2 >1 8 2 >1 9 2 >1 10 2 >1 13 3 >1 14 3 >1 15 3 >2 2 1 >2 3 1 >2 4 1 >2 5 1 >2 6 1 >2 7 1 >2 15 2 >2 16 2 >2 17 2 >2 18 2 >2 19 2 > >Is anyone know how to do that ? >Any suggestion is appreciated. > >Kai


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