Hi,
I have a dataset with clam ,line and ind field.
1. when the whole clamno has the rev =Y only, then need to select Y .
2. When the clamno has the rev=Y and N , then need to select only 'N'.data have;
input (CLAM LNNO IND) ($);cards
;
12345 001 Y
12345 002 Y
12345 003 Y
23456 001 Y
23456 002 N
34567 001 Y
34567 002 N
34567 003 N
78968 001 Y
78968 002 Y
78968 003 Y
;
output should be:
12345 001 Y
12345 002 Y
12345 003 Y
23456 002 N
34567 002 N
34567 003 N
78968 001 Y
78968 002 Y
78698 003 Y
Thanks in Advance
data have;
input (CLAM LNNO IND) ($);
cards
;
12345 001 Y
12345 002 Y
12345 003 Y
23456 001 Y
23456 002 N
34567 001 Y
34567 002 N
34567 003 N
78968 001 Y
78968 002 Y
78968 003 Y
;
run;
proc sort data=have; by clam ind; run;
data want;
set have;
by clam ind;
if first.clam then del=0;
if ind='N' then del+1;
if ind='Y' and del>0 then delete;
drop del;
run;
It works well !! Thanks a lot !!!
I want to know when the whole clamno has the rev =N only, What you want to do?
Ksharp
Hi Sharp,
In that case we need to pick the whole clamno has the rev=N only.
For example,
clamno line rev
123 1 Y
123 2 Y
234 1 Y
234 2 N
567 1 N
567 2 N
OUTPUT SHOULD BE
123 1 Y
123 2 Y
234 2 N
567 1 N
567 2 N
Thanks.
Thus, FriedEgg's code will work for that situation as well. You really ought to give him credit for having answered the question.
Yes Sure Art !! He resolved the problem for me with in few minutes !!!
Thanks FriedEgg !!!
I'm sure he will appreciate that. But, if you don't indicate that the correct answer has been given, others will still spend time trying to provide you with a solution.
Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.
Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.
Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.
Find more tutorials on the SAS Users YouTube channel.