home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #16 / NN_1992_16.iso / spool / bit / listserv / sasl / 3368 < prev    next >
Encoding:
Text File  |  1992-07-21  |  2.1 KB  |  52 lines

  1. Comments: Gated by NETNEWS@AUVM.AMERICAN.EDU
  2. Path: sparky!uunet!paladin.american.edu!auvm!DUKEMVS.BITNET!DROBBY
  3. Message-ID: <SAS-L%92072015255875@VTVM2.BITNET>
  4. Newsgroups: bit.listserv.sas-l
  5. Date:         Mon, 20 Jul 1992 15:24:00 EDT
  6. Reply-To:     DROBBY@DUKEMVS.BITNET
  7. Sender:       "SAS(r) Discussion" <SAS-L@UGA.BITNET>
  8. From:         DROBBY@DUKEMVS.BITNET
  9. Subject:      Sorting Puzzle - Multiple variable sorts
  10. Lines: 40
  11.  
  12. Dear SAS-L'ers,
  13.      Sometimes, just when you think you understand the SAS algorithms,
  14.      something pops up and make you existentially insecure. Consider
  15.      the following.
  16.         A student was trying to sort two datasets by, say, id and
  17.      school, in order to merge them together.  She clearly wanted
  18.      the dataset to look like id's within school's. She tried
  19.      the following code:
  20.  
  21.       proc sort data=one;
  22.          by school;
  23.          by id;
  24.  
  25.       proc sort data=two;
  26.          by school;
  27.          by id;
  28.  
  29.       data total;
  30.           merge one two;
  31.        by school;
  32.        by id;
  33.  
  34.       Needless to say,  the merge did not work, as it did not find
  35.       the datasets "sorted" by school.  I straightened her out by
  36.       showing her how to use just one by statement with multiple
  37.       variables, and explained to her how I thought SAS was
  38.       interpreting her code.  That is, first sort by school;  then,
  39.       resort by ID, independent of school, leaving her with the
  40.       wrong look to her dataset).  Anyway, she left and then she
  41.       came back with a printout based on the two BY statement code
  42.       that suggested that the datasets were indeed sorted by id within
  43.       school, antithetical to my hypothesis.
  44.          Anyway, what gives?  Can anyone suggest what SAS is doing here?
  45.  
  46.                                           Dr. Robert Terry
  47.                                           Dept. of Psychology
  48.                                           Social and Health Sciences
  49.                                           Duke University
  50.                                           Durham, NC 27708
  51.                                           EMAIL: drobby@dukemvs
  52.