home *** CD-ROM | disk | FTP | other *** search
- Comments: Gated by NETNEWS@AUVM.AMERICAN.EDU
- Path: sparky!uunet!paladin.american.edu!auvm!COMPUSERVE.COM!76350.1604
- Message-ID: <920828134856_76350.1604_EHJ22-1@CompuServe.COM>
- Newsgroups: bit.listserv.sas-l
- Date: Fri, 28 Aug 1992 09:48:56 EDT
- Reply-To: Andy Norton <76350.1604@COMPUSERVE.COM>
- Sender: "SAS(r) Discussion" <SAS-L@UGA.BITNET>
- From: Andy Norton <76350.1604@COMPUSERVE.COM>
- Subject: Re: print dup records
- Comments: To: SAS-L <SAS-L@AWIIMC12.IMC.UNIVIE.AC.AT>
- Lines: 51
-
- ----------------------------------------------------------------------
- CONTENT: Response
- SUMMARY: Printing duplicate records
- REL/PLTF: 6.07.01/CMS, 6.04/PC-DOS
- E-ADDR: 76350.1604@compuserve.com
- NAME: Andy Norton
- ADDRESS: Trilogy Consulting, 5228 Lovers Lane, Kalamazoo MI 49002
- PHONE: (616) 344-2191
- ----------------------------------------------------------------------
-
- ON Fri, 28 Aug 1992 08:37:07 EST
- LYCACC%RITVM.BITNET@uga.cc.uga.edu WROTE:
-
- > I wonder if anyone knows a "easy" way to print duplicate records in
- a
- > data set.
- >
- > Thanks in advance,
- > Loyi
-
- Ray Pass responded with a method that works, but does not print the
- first record in the by-group. If you want to see all records within
- the duplicated group use
- proc sort data=ORIG;
- by IDNO;
- run;
-
- data DUPS;
- set ORIG;
- by IDNO;
- if not (first.IDNO and last.IDNO);
- run;
-
- proc print data=DUPS;
- run;
- I'm sure this trick has been rediscovered many times, but I first
- learned it from Grant Blank.
-
- Or, in SQL (no sorting necessary), use
- proc sql;
- select *
- from ORIG
- group by IDNO
- having count(*) > 1;
- quit;
- This will print automatically.
-
- Note! This is not standard SQL. It takes advantage of the SAS
- "re-merging" enhancement, which joins the IDNO's satisfying the HAVING
- clause with the data set ORIG. You don't have to worry about this
- unless you try to use this program outside of SAS (such as in ORACLE).
-