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 2000, week 2)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Tue, 10 Oct 2000 12:26:36 +0200
Reply-To:     Ace <b.rogers@VIRGIN.NET>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         Ace <b.rogers@VIRGIN.NET>
Subject:      Re: Duplicate Observations!
Content-Type: text/plain; charset=us-ascii

ylau1@irix2.gl.umbc.edu wrote: > > Hi, just want to verify a few things. In the real dataset, there are over 100 > variables, I am looking for a way to obtain the duplicates without typing > out all variable names, as they are not named Var1 to Var100. The variables > may be either Character or Numeric type. Thanks for any help.

Anna,

I see lots of different solutions have been suggested, but here's one (untested) that checks for duplication of all variables in sequential records (which seems to be the case in your examples) without sorting.

data new; set old; array nums _numeric_ ; array chars _char_ ; array oldnums oldn1-oldn999 ; /*set 999 to >= max # of num variables */ array oldchar oldc1-oldc999 ; /*set 999 to >= max # of char variables */ retain oldn1-oldn999 oldc1-oldc999 ; drop oldn1-oldn999 oldc1-oldc999 ; alike = 1 ; do i = 1 to dim(nums) ; if nums(i) ^= oldnums(i) then alike = 0 ; oldnums(i) = nums(i) ; end; do i = 1 to dim(chars) ; if chars(i) ^= oldchars(i) then alike = 0 ; oldchars(i) = chars(i) ; end; if alike then do ; output ; /* and another output ; if you actually want all dup. recs */ end; run;

HTH -- Bruce


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