home *** CD-ROM | disk | FTP | other *** search
- Comments: Gated by NETNEWS@AUVM.AMERICAN.EDU
- Path: sparky!uunet!paladin.american.edu!auvm!SWIRL.MONSANTO.COM!GIBES
- Message-ID: <9207310435.AA09844@tin.monsanto.com>
- Newsgroups: bit.listserv.sas-l
- Date: Thu, 30 Jul 1992 23:35:26 -0500
- Reply-To: Kernon Gibes <gibes@SWIRL.MONSANTO.COM>
- Sender: "SAS(r) Discussion" <SAS-L@UGA.BITNET>
- From: Kernon Gibes <gibes@SWIRL.MONSANTO.COM>
- Subject: RE: Reading Data Conditionally
- Comments: To: SAS-L@uga.cc.uga.edu@tin.monsanto.com
- Comments: cc: xiang@u.washington.edu@tin.monsanto.com, GIBES@tin.monsanto.com
- Lines: 67
-
- CONTENT: Response to Xiang's "Reading Data Conditionally"
- SUMMARY: Output only the 1st occurances of values with retained flags
- REL/PLTF: not applicable
- E-ADDR: gibes@swirl.monsanto.com
- NAME: Kernon Gibes
- PHONE: (708) 506-2873
- DATE/TIME: 30 July 1992
-
- Regarding:
-
- > Now I need to select observations based on Resp Values: Select
- >the very first observation where resp=1 or resp=2. In the data above,
- >it will be the fourth observation: 0.76 90 1 0, and the eighth
- >observation: 1.02 83 2 0.
- >
- > I appreciate your comments. Since I don't check this newsgroup
- >often enough, please respond to me at xiang@u.washington.edu.
- >For those of you who feel this is too easy to be put on the net,
- >please be tolerant. Thank you.
-
- Personally, I appreciate the "easy" questions... they're the only ones I
- can answer:
-
- ___ source code ________________________________________________________
-
- options ls=72 nodate nonumber;
- data test;
- input Time Stimul Resp Tooth;
- cards;
- 0.59 70 0 0
- 0.63 75 0 0
- 0.71 80 0 0
- 0.76 90 1 0
- 0.79 103 1 0
- 0.88 79 0 0
- 0.97 81 0 0
- 1.02 83 2 0
- 1.06 90 0 1
- ;
-
- data subset;
- set test;
- retain flag1 1 flag2 1;
- if flag1 and resp = 1 then do;
- oldobs = _n_;
- flag1 = 0;
- output;
- end;
- if flag2 and resp = 2 then do;
- oldobs = _n_;
- flag2 = 0;
- output;
- end;
- run;
-
- proc print data=subset;
- title1 "should have 4th obs(0.76 90 1 0) and 8th obs (1.02 83 2 0.)";
- run;
-
- ___ SAS output _________________________________________________________
-
- should have 4th obs(0.76 90 1 0) and 8th obs (1.02 83 2 0.)
-
- OBS TIME STIMUL RESP TOOTH FLAG1 FLAG2 OLDOBS
-
- 1 0.76 90 1 0 0 1 4
- 2 1.02 83 2 0 0 0 8
-