```Date: Tue, 19 Oct 2010 20:00:48 -0400 Reply-To: Nat Wooding Sender: "SAS(r) Discussion" From: Nat Wooding Subject: Re: Hash or No-Hash solution to my problem? Comments: To: Raghav Adimulam In-Reply-To: <201010192242.o9JH5kER012853@willow.cc.uga.edu> Content-Type: text/plain; charset="us-ascii" This is not as slick as the SQL solution but for those who do not do SQL, it is an alternative. Nat Wooding Data NOHash; input MRN \$3. DateDiff; cards; 001 500 001 400 001 300 001 200 001 100 001 0 002 500 002 400 002 300 002 200 002 100 003 700 003 300 003 200 003 50 ; Data NoHash; set nohash; by mrn; if first.mrn then count=0; count+1; run; Proc Transpose data=nohash out = nohash (drop = _name_ ) Prefix = Col; by mrn; id count; var DateDiff; Run; Data NoHash; set nohash; Keep MRN DateDiff; Array A col: ; MinDiff = Min( of col: ); Do _I_ = 1 to Dim(a) ; DateDiff = A(_I_); if Datediff = . then return; if abs( MinDiff - DateDiff) lt 365 then output; end; Run; -----Original Message----- From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] On Behalf Of Raghav Adimulam Sent: Tuesday, October 19, 2010 6:43 PM To: SAS-L@LISTSERV.UGA.EDU Subject: Hash or No-Hash solution to my problem? Hello SAS-Lers, Here is the simplified version of my problem, i.e. without the unnecessary fields and misc data. I have a dataset with 2 fields that is sorted on MRN and DateDiff as shown below. MRN DateDiff 001 500 001 400 001 300 001 200 001 100 001 0 002 500 002 400 002 300 002 200 002 100 003 700 003 300 003 200 003 50 How can I accomplish a task so that I can keep only the records that fall within 365 days of the lowest DateDiff for that MRN?? In other words, MRN 001 has qualifying records <=0+365 MRN 002 has qualifying records <=100+365 (=465) MRN 003 has qualifying records <=50+365 (=415) Thus the final dataset should be.. MRN DateDiff 001 300 001 200 001 100 001 0 002 400 002 300 002 200 002 100 003 300 003 200 003 50 Thanks for your answers in advance! -Raghav ```

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