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 (October 2002, week 3)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:   Thu, 17 Oct 2002 16:23:33 -0400
Reply-To:   "Chakravarthy, Venky" <Venky.Chakravarthy@PFIZER.COM>
Sender:   "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:   "Chakravarthy, Venky" <Venky.Chakravarthy@PFIZER.COM>
Subject:   Re: Flag
Comments:   To: Asheber Sewalem <sewalem@CDN.CA>
Content-Type:   text/plain; charset="iso-8859-1"

You have already received some good solutions. For variety here is a single data step approach reading the data twice.

data flagthis ; input id x1 ; cards ; 12 2 12 3 12 -1 13 5 13 6 13 6 14 4 14 -3 14 3 run ;

data flagged ; do until ( last.id or x1 < 0 ) ; set flagthis ; by id ; if x1 < 0 then x2 = -2 ; else x2 = 2 ; end ; do until ( last.id ) ; set flagthis ; by id ; output ; end ; run ;

Kind Regards, __________________________ Venky Chakravarthy E-mail: swovcc@hotmail.com

-----Original Message----- From: Asheber Sewalem [mailto:sewalem@CDN.CA] Sent: Thursday, October 17, 2002 2:46 PM To: SAS-L@LISTSERV.UGA.EDU Subject: Flag

Hi all,

A simple question! I have two variables id and x1. I just want to flag all "Id" records -2 if any of the records x1 within id is less than 0 otherwise flag=2.

A sample data,

id x1 12 2 12 3 12 -1 13 5 13 6 13 6 14 4 14 -3 14 3

The desired output should be the following,

id x1 flag 12 2 -2 12 3 -2 12 -1 -2 13 5 2 13 6 2 13 6 2 14 4 -2 14 -3 -2 14 3 -2

Asheber


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