```Date: Thu, 5 Oct 2006 13:15:08 -0400 Reply-To: "data _null_;" Sender: "SAS(r) Discussion" From: "data _null_;" Subject: Re: data filter problem Comments: To: y y In-Reply-To: <20061005161725.218.qmail@web58514.mail.re3.yahoo.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed You first need to determine the IDs that meet the selection criterion then select the observations that meet it. The following data could be used to accomplish that task. proc sort data=work.one; by id; run; data work.Y2Q4(drop=_yq: n d); array _yq(2,4); d = nmiss(of _yq:); do until(last.id); set work.one; by id year quarter; _yq[year,quarter]=1; end; n = n(of _yq:); do until(last.id); set work.one; by id; if n eq d then output; end; run; proc print; run; On 10/5/06, y y wrote: > Dear all, > I have a data set with ID across 2 years and 4 quarters. > > data one; > input ID X year quarter; > cards; > 1 3 1 1 > 2 4 1 1 > 3 2 1 1 > 1 5 1 2 > 3 6 1 2 > 1 4 1 3 > 2 6 1 3 > 4 8 1 3 > 1 5 1 4 > 1 7 2 1 > 1 5 2 2 > 2 4 2 2 > 1 6 2 3 > 1 7 2 4 > ; > run; > > I want the observations with the same ID across the years(1,2) and quarters(1,2,3,4). So the desired result should be > > ID X year quarter > 1 3 1 1 > 1 5 1 2 > 1 4 1 3 > 1 5 1 4 > 1 7 2 1 > 1 5 2 2 > 1 6 2 3 > 1 7 2 4 > > Anyone know how to solve this problem? > Your help will be highly appreciated!! > > > --------------------------------- > Why keep checking for Mail? The all-new Yahoo! Mail shows you when there are new messages. > ```

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