Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Eliminating obs

Status
Not open for further replies.

wphupkes

Technical User
Jul 1, 2008
22
NL
I hope someone can help me with the following:

I like to eliminate the obs when they are greater than age>=ag1 by id. See below for the input set.

id age ag1

1 1 .
1 2 2
1 3 .
2 1 1
2 2 .
2 3 .
3 1 .
3 2 .
3 3 3
3 4 .

I've used the following code already:


data test1;
set test;
by id;
if first.id or not first.id then do;
if age>=ag1 then delete;
end;
run;

But with the code above, all obs were dropped.

Trying this:

data test1;
set test;
by id;
if first.id or not first.id then do;
if age>=ag1 and ag1 ne . then delete;
end;
run;

will result in this:

1 1 .
1 3 .
2 2 .
2 3 .
3 1 .
3 2 .
3 4 .


So all values of age1 are dropped and the missing values if age>age1 are present. What to do?


Thanks for your time in advance!!

With kind regards.,
Wouter
wphupkes@gmail.com

Business / Risk Analyst
wphupkes@gmail.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top