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
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