Date: Thu, 17 Oct 2002 15:39:51 -0400
Reply-To: Ed Heaton <EdHeaton@WESTAT.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Ed Heaton <EdHeaton@WESTAT.COM>
Subject: Re: Flag
Content-Type: text/plain; charset="iso-8859-1"
Asheber;
Given the data set created below.
Data test ;
Infile cards ;
Input id x1 ;
Cards4 ;
12 2
12 3
12 -1
13 5
13 6
13 6
14 4
14 -3
14 3
;;;;
You can use this two-step process.
Proc sql ;
Create table flags as
select id , min(x1) as min
from test
group by id
;
Quit ;
Data FlaggedTest(drop=min) ;
Merge test flags ;
By id ;
If ( min < 0 )
then flag = -2 ;
Else flag = 2 ;
Run ;
Ed
Edward Heaton, Senior Systems Analyst,
Westat (An Employee-Owned Research Corporation),
1550 Research Boulevard, Room 2018, Rockville, MD 20850-3195
Voice: (301) 610-4818 Fax: (301) 294-3992
mailto:EdHeaton@westat.com http://www.westat.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