home *** CD-ROM | disk | FTP | other *** search
- Comments: Gated by NETNEWS@AUVM.AMERICAN.EDU
- Path: sparky!uunet!paladin.american.edu!auvm!NIHCU.BITNET!HIS
- Message-ID: <SAS-L%92081714175451@UGA.CC.UGA.EDU>
- Newsgroups: bit.listserv.sas-l
- Date: Mon, 17 Aug 1992 14:15:28 EDT
- Reply-To: Howard Schreier <HIS@NIHCU.BITNET>
- Sender: "SAS(r) Discussion" <SAS-L@UGA.BITNET>
- From: Howard Schreier <HIS@NIHCU.BITNET>
- Subject: Re: SQL delete statement
- Lines: 78
-
- CONTENT: Response
- SUMMARY: Use SQL correlated subquery to implement "delete list"
- REL/PLTF: 6.06+
-
- From Don MacQueen (macq@miguel.llnl.gov):
-
- > I have a very large dataset, from which I would like to
- > delete a number of observations. This dataset is large
- > enough that I am running short on disk space. The
- > information about which cases to delete comes from another
- > dataset, based on some key variables.
- >
- > Normally, I would do something like this:
- >
- > data new;
- > merge big dels (in=indel);
- > by area analyte;
- > if indel then delete;
- > run;
- >
- > Where there are many observations in big for each
- > combination of area and analyte, but each combination of
- > area and analyte only appears once in dels.
- >
- > I thought I'd look at proc sql. Seems like something such
- > as
- >
- > proc sql;
- > delete from big
- > where big.area=dels.area and big.analyte=dels.analyte;
- >
- > ought to work, but It doesn't, and I don't know SQL well
- > enough to fix it.
-
- Try adapting the example on the bottom of p. 129 of the SQL
- FM:
-
- delete from big where exists
- (select * from dels where
- big.area=dels.area and big.analyte=dels.analyte);
-
- Test table BIG (before):
-
- AREA ANALYTE OTHER
- ----------------------------
- 1 1 22
- 1 2 33
- 1 2 44
- 2 1 55
- 2 2 66
- 3 3 77
-
- Test table DELS:
-
- AREA ANALYTE
- ------------------
- 1 2
- 2 2
-
- Test table BIG (after):
-
- AREA ANALYTE OTHER
- ----------------------------
- 1 1 22
- 2 1 55
- 3 3 77
-
- This employees a "correlated subquery"; in other words, a
- subquery which has to be evaluated for each row of the main
- table. I'm not sure that this will be efficient for your
- situation.
-
- /\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
- \ Howard Schreier, U.S. Dept. of Commerce, Washington /
- / MVS 5.18 & 6.07 \
- \ Voice: (202) 377-4180 BITNET: HIS@NIHCU /
- / Fax: (202) 377-4614 INTERNET: HIS@CU.NIH.GOV \
- \/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/
-