Date: Fri, 2 Apr 2004 07:47:07 -0500
Reply-To: Nathaniel_Wooding@DOM.COM
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Nat Wooding <Nathaniel_Wooding@DOM.COM>
Subject: Re: tricky data extraction
Content-type: text/plain; charset=us-ascii
Jim's reply was close but needed some tweaking. In particular, not that one
needs a "notsorted" on the by statement.
Nat Wooding
data a;
input obs var1 var2;
cards;
1 1 1.1001113E17
2 2 20031231
3 1 1.1001113E17
4 2 20040110
5 2 20040108
6 2 20040108
7 2 20040108
8 1 1.1001113E17
9 2 20040110
10 1 1.1001113E17
11 2 20040110
12 1 1.1001113E17
13 2 20040110
14 2 20031213
15 2 20031222
16 2 20031222
17 2 20031225
data b;
set a;
by var1 notsorted;
if (not first.var1 and var1 =2) then delete;
proc print;run;
neumann
<geekaxl@21CN.COM To: SAS-L@LISTSERV.UGA.EDU
> cc:
Sent by: "SAS(r) Subject: tricky data extraction
Discussion"
<SAS-L@LISTSERV.U
GA.EDU>
04/02/04 01:18 AM
Please respond to
neumann
Obs VAR1 VAR2
1 1 1.1001113E17
2 2 20031231
3 1 1.1001113E17
4 2 20040110
5 2 20040108
6 2 20040108
7 2 20040108
8 1 1.1001113E17
9 2 20040110
10 1 1.1001113E17
11 2 20040110
12 1 1.1001113E17
13 2 20040110
14 2 20031213
15 2 20031222
16 2 20031222
17 2 20031225
hi all,
i have a dataset listed upside, what i want to do is to extract
every observation pair whose VAR1 is '1' and '2', when the VAR1 equals
1, it's a ID number , and when VAR1 equals 2, it's a meaningful record
which i want to use, the rest should be deleted,and when it's done, it
should be like this:
Obs VAR1 VAR2
1 1 1.1001113E17
2 2 20031231
3 1 1.1001113E17
4 2 20040110
8 1 1.1001113E17
9 2 20040110
10 1 1.1001113E17
11 2 20040110
12 1 1.1001113E17
13 2 20040110
anyone knows how to get this done? i need your suggestions, Thanx in
advance!