home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #19 / NN_1992_19.iso / spool / bit / listserv / sasl / 3937 < prev    next >
Encoding:
Text File  |  1992-08-29  |  1.7 KB  |  49 lines

  1. Comments: Gated by NETNEWS@AUVM.AMERICAN.EDU
  2. Path: sparky!uunet!paladin.american.edu!auvm!SWIRL.MONSANTO.COM!GIBES
  3. Message-ID: <9208281329.AA17498@tin.monsanto.com>
  4. Newsgroups: bit.listserv.sas-l
  5. Date:         Fri, 28 Aug 1992 08:29:08 -0500
  6. Reply-To:     Kernon Gibes <gibes@SWIRL.MONSANTO.COM>
  7. Sender:       "SAS(r) Discussion" <SAS-L@UGA.BITNET>
  8. From:         Kernon Gibes <gibes@SWIRL.MONSANTO.COM>
  9. Subject:      RE: print dup records
  10. Comments: To: SAS-L@uga.cc.uga.edu@tin.monsanto.com
  11. Comments: cc: GIBES@tin.monsanto.com
  12. Lines: 35
  13.  
  14.  CONTENT:   Response (to printing duplicate records only)
  15.  SUMMARY:   A possible SQL approach
  16.  REL/PLTF:  6.06+/n.a.
  17.  E-ADDR:    gibes@swirl.monsanto.com
  18.  NAME:      Kernon Gibes
  19.  DATE:      28 August 1992
  20.  
  21. Regarding:
  22.  
  23. >I wonder if anyone knows a "easy" way to print duplicate records in a
  24. >data set.  Proc sort has an option to drop duplicates, but nothing to
  25. >keep the duplicates only.  I suppose I can use a do loop in DATA step
  26. >to check for duplicates, but is there an easier way?  We are running
  27. >SAS607 on MVS, and CMS.
  28.  
  29. and, from Ray,
  30.  
  31. >That was an "easy" one.  And now for the SQL answer.  Howard ?
  32.  
  33. Well, I'm no Howard, but:
  34.  
  35.   proc sql;
  36.     select * from org
  37.     group by idno
  38.     having count(idno) > 1
  39.     ;
  40.   quit;
  41.  
  42. will mimic Ray's solution except that if the records are PURE
  43. duplicates, each IDNO will be printed only once.  If the records are
  44. only duplicates with respect to IDNO but other variables differ, the
  45. above SQL code will list ALL the records for each IDNO having duplicate
  46. values.  If there is more than one key, the code, like Ray's, would have
  47. to be expanded.  It wasn't clear to me exactly how extensive the
  48. duplicate record situation was.
  49.