Date: Fri, 11 Aug 2006 10:42:01 -0700 Reply-To: "Terjeson, Mark (IM&R)" Sender: "SAS(r) Discussion" From: "Terjeson, Mark (IM&R)" Subject: Re: Easy Selection Question Comments: To: gbruintjes In-Reply-To: A<1155315455.384975.272260@m73g2000cwd.googlegroups.com> Content-Type: text/plain; charset="us-ascii" Hi Gerrit, Nat has given you a nifty datastep solution. Here is an SQL approach: data gerrit; * sample data c/o Nat ; input id result desire \$20.; cards; 15648456 -12 15648456 -3 15648456 2 <= want to keep 15648456 12 5423156 -60 5423156 -12 5423156 -5 <= want to keep 86542123 1 <= want to keep 86542123 10 86542123 20 ; run; proc sql; create table final as select id, result, desire from gerrit group by id having min(abs(result)) eq abs(result) ; quit; Hope this is helpful. Mark Terjeson Senior Programmer Analyst, IM&R Russell Investment Group Russell Global Leaders in Multi-Manager Investing -----Original Message----- From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] On Behalf Of gbruintjes Sent: Friday, August 11, 2006 9:58 AM To: SAS-L@LISTSERV.UGA.EDU Subject: Easy Selection Question I'm somewhat new to SAS so hopefully this will be easy to answer. I have a data set with multiple entries for individuals. Each individual ID is unique but may have more than one observation in the data set. I have an additional variable (result) that contains results for each individual (both negative and positive). I need to find the lowest positive number for this variable for each individual. If there is no positive number the number closest to 0 is fine. I just need to make sure that each individual ID is in there only once even if they do not have a positive number. I sorted the data by ID and result but got stuck. example: 15648456 -12 15648456 -3 15648456 2 <= want to keep 15648456 12 5423156 -60 5423156 -12 5423156 -5 <= want to keep 86542123 1 <= want to keep 86542123 10 86542123 20 Thanks, Gerrit

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