LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous messageNext messagePrevious in topicNext in topicPrevious by same authorNext by same authorPrevious page (October 2009, week 4)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Thu, 22 Oct 2009 14:33:41 -0500
Reply-To:     "Data _null_;" <iebupdte@GMAIL.COM>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         "Data _null_;" <iebupdte@GMAIL.COM>
Subject:      Re: data manipulation problem
Comments: To: olivesecret <olivesecret@gmail.com>
In-Reply-To:  <800fdcbd-11a4-472c-80dd-efacb4d303b5@m13g2000vbf.googlegroups.com>
Content-Type: text/plain; charset=ISO-8859-1

This appears to work using the data you posted. I don't know how it will work with your real data. It might be useful as a check of the other methods or to show that it does not work.

data test; input id:1. y @@; array yy[10]; do _n_ = 1 to dim(yy); yy[_n_] = rannor(345785); end; cards; 1 1 1 1 1 1 1 0.8 1 0.6 1 0.6 1 0.4 1 0.2 2 1 2 1 2 0.4 2 0 3 1 3 1 3 0.8 3 0.8 4 1 ;;;; run; data testV / view=testV; set test(keep=id y); x = y-.5; s = sign(x); run; proc summary nway data=testV; class id; output out=obs(drop=_type_ _freq_) idgroup(max(s) min(x) obs out[1](y)=idY1) idgroup(min(s) max(x) obs out[1](y)=idY2) / autoname ; run; proc print; run; data subset; set obs; do point = _obs_,_obs2_; set test point=point; output; end; run; proc print; run; On 10/22/09, olivesecret <olivesecret@gmail.com> wrote: > I have a large data set consisting of subject id, response y and other > interesting variables. A subset of data is like this: > > ID Y ... > 1 1 > 1 1 > 1 1 > 1 0.8 > 1 0.6 > 1 0.6 > 1 0.4 > 1 0.2 > 2 1 > 2 1 > 2 0.4 > 2 0 > 3 1 > 3 1 > 3 0.8 > 3 0.8 > 4 1 > ... > > What I need do is for each ID, find the two observations, with one > having y immediately larger than 0.5 and the other having y > immediately smaller 0.5. For the example above, then the observations > needed for ID=1 are ID=1 y=0.6 and ID=1 y=0.4, and the observations > needed for ID=2 are ID=2 y=1 and ID=2 y=0.4. For ID=3, since there are > no observations where y is less than 0.5, then I need the the two obs > which having y immediately larger than 0.5, which are ID=3 y=1 and > ID=3 y=0.8. > Any hints? > Thanks a lot! >


Back to: Top of message | Previous page | Main SAS-L page