```Date: Tue, 18 Mar 2003 17:04:38 -0500 Reply-To: Wenge Guo Sender: "SAS(r) Discussion" From: Wenge Guo Subject: Re: Deleting rows (sorted columnwise) On Mon, 17 Mar 2003 15:17:25 -0800, Paul Choate wrote: >It was pointed out to me that my method won't work if you have >duplicate values, such as 2-2-2 and 3-1-1. If this is the case, and >the numbers are small, such as fewer than 10 each of integers 0-9, you >could work around duplicates by using powers of 10 rather than 2. For >example 3011200012 would be the set 0,0,1,5,5,6,7,9,9,9, or 10^0 + >10^0 + 10^1 + 10^5 + 10^5 + 10^6 + 10^7 + 10^9 + 10^9 + 10^9 > >-Paul > >pchoate@dds.ca.gov (Paul Choate) wrote in message news:... >> Richard - >> >> In a similar situation I've used sums of powers of 2 (2^n) where n are >> the data values. Note that the powers of two are 1,2,4,8,16,etc and >> each unique subset will sum to a unique integer. This is the same as >> assigning a unique binary number to each set of values: your "3 1 4" >> will be 2^3+2^1+2^4=26 decimal which is 11010 binary. Put a counter >> on your data, sort, and unduplicate on the first by-group observation. >> >> hope that helps >> >> Paul Choate >> >> > >> > -----Original Message----- >> > From: SAS(r) Discussion [mailto:SAS-L@listserv.uga.edu] On Behalf Of >> > Richard A. DeVenezia >> > Sent: Friday, March 14, 2003 2:38 AM >> > To: SAS-L@listserv.uga.edu >> > Subject: Q: Deleting rows (sorted columnwise) >> > >> > I have some data in columns A, B, C and want to delete all but first >> > occurring row where the values are the same if the values were sorted. >> > >> > A B C >> > 3 1 4 >> > 1 2 3 >> > 4 1 3 * remove (same as 3 1 4) >> > 3 2 5 >> > 3 2 1 * remove (same as 1 2 3) >> > 1 3 4 * remove (same as 3 1 4) >> > >> > Is there a way to remove the rows with out needing to sort each row by >> > A,B,C >> > ? Try to run the following program. Orderal function seems to provide a feasible solution. data temp; input A B C; j=_n_; array order[*] order1-order3; do i=1 to 3 by 1; order[i]=ordinal(i,a,b,c); end; drop i; datalines; 3 1 4 1 2 3 4 1 3 3 2 5 3 2 1 1 3 4 ; run; data result; set temp; by order1 order2 order3 notsorted; if (first.order1 and first.order2 and first.order3); keep a b c; run; best, wenge wenge.guo@ndsu.nodak.edu ```

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