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

  1. Comments: Gated by NETNEWS@AUVM.AMERICAN.EDU
  2. Path: sparky!uunet!paladin.american.edu!auvm!SWIRL.MONSANTO.COM!GIBES
  3. Message-ID: <9207310435.AA09844@tin.monsanto.com>
  4. Newsgroups: bit.listserv.sas-l
  5. Date:         Thu, 30 Jul 1992 23:35:26 -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: Reading Data Conditionally
  10. Comments: To: SAS-L@uga.cc.uga.edu@tin.monsanto.com
  11. Comments: cc: xiang@u.washington.edu@tin.monsanto.com, GIBES@tin.monsanto.com
  12. Lines: 67
  13.  
  14.  CONTENT:   Response to Xiang's "Reading Data Conditionally"
  15.  SUMMARY:   Output only the 1st occurances of values with retained flags
  16.  REL/PLTF:  not applicable
  17.  E-ADDR:    gibes@swirl.monsanto.com
  18.  NAME:      Kernon Gibes
  19.  PHONE:     (708) 506-2873
  20.  DATE/TIME: 30 July 1992
  21.  
  22. Regarding:
  23.  
  24. >  Now I need to select observations based on Resp Values: Select
  25. >the very first observation where resp=1 or resp=2. In the data above,
  26. >it will be the fourth observation: 0.76 90 1 0, and the eighth
  27. >observation: 1.02 83 2 0.
  28. >
  29. >  I appreciate your comments.  Since I don't check this newsgroup
  30. >often enough, please respond to me at xiang@u.washington.edu.
  31. >For those of you who feel this is too easy to be put on the net,
  32. >please be tolerant. Thank you.
  33.  
  34. Personally, I appreciate the "easy" questions... they're the only ones I
  35. can answer:
  36.  
  37. ___ source code ________________________________________________________
  38.  
  39. options ls=72 nodate nonumber;
  40. data test;
  41.  input  Time    Stimul    Resp    Tooth;
  42. cards;
  43.    0.59    70        0         0
  44.         0.63    75        0         0
  45.         0.71    80        0         0
  46.         0.76    90        1         0
  47.         0.79    103       1         0
  48.         0.88    79        0         0
  49.         0.97    81        0         0
  50.         1.02    83        2         0
  51.         1.06    90        0         1
  52. ;
  53.  
  54. data subset;
  55.    set test;
  56.    retain flag1 1 flag2 1;
  57.    if flag1 and resp = 1 then do;
  58.       oldobs = _n_;
  59.       flag1 = 0;
  60.       output;
  61.       end;
  62.    if flag2 and resp = 2 then do;
  63.       oldobs = _n_;
  64.       flag2 = 0;
  65.       output;
  66.       end;
  67. run;
  68.  
  69. proc print data=subset;
  70. title1 "should have 4th obs(0.76 90 1 0) and 8th obs (1.02 83 2 0.)";
  71. run;
  72.  
  73. ___ SAS output _________________________________________________________
  74.  
  75.       should have 4th obs(0.76 90 1 0) and 8th obs (1.02 83 2 0.)
  76.  
  77.    OBS    TIME    STIMUL    RESP    TOOTH    FLAG1    FLAG2    OLDOBS
  78.  
  79.     1     0.76      90        1       0        0        1         4
  80.     2     1.02      83        2       0        0        0         8
  81.