home *** CD-ROM | disk | FTP | other *** search
- Comments: Gated by NETNEWS@AUVM.AMERICAN.EDU
- Path: sparky!uunet!paladin.american.edu!auvm!DUKEMVS.BITNET!DROBBY
- Message-ID: <SAS-L%92072015255875@VTVM2.BITNET>
- Newsgroups: bit.listserv.sas-l
- Date: Mon, 20 Jul 1992 15:24:00 EDT
- Reply-To: DROBBY@DUKEMVS.BITNET
- Sender: "SAS(r) Discussion" <SAS-L@UGA.BITNET>
- From: DROBBY@DUKEMVS.BITNET
- Subject: Sorting Puzzle - Multiple variable sorts
- Lines: 40
-
- Dear SAS-L'ers,
- Sometimes, just when you think you understand the SAS algorithms,
- something pops up and make you existentially insecure. Consider
- the following.
- A student was trying to sort two datasets by, say, id and
- school, in order to merge them together. She clearly wanted
- the dataset to look like id's within school's. She tried
- the following code:
-
- proc sort data=one;
- by school;
- by id;
-
- proc sort data=two;
- by school;
- by id;
-
- data total;
- merge one two;
- by school;
- by id;
-
- Needless to say, the merge did not work, as it did not find
- the datasets "sorted" by school. I straightened her out by
- showing her how to use just one by statement with multiple
- variables, and explained to her how I thought SAS was
- interpreting her code. That is, first sort by school; then,
- resort by ID, independent of school, leaving her with the
- wrong look to her dataset). Anyway, she left and then she
- came back with a printout based on the two BY statement code
- that suggested that the datasets were indeed sorted by id within
- school, antithetical to my hypothesis.
- Anyway, what gives? Can anyone suggest what SAS is doing here?
-
- Dr. Robert Terry
- Dept. of Psychology
- Social and Health Sciences
- Duke University
- Durham, NC 27708
- EMAIL: drobby@dukemvs
-