BookmarkSubscribeRSS Feed
raveena
Obsidian | Level 7

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

7 REPLIES 7
FriedEgg
SAS Employee

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;

raveena
Obsidian | Level 7

It works well !! Thanks a lot !!!

Ksharp
Super User

I want to know    when the whole clamno has the rev =N  only, What  you want to do?

Ksharp

Smiley Happy

raveena
Obsidian | Level 7

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.

art297
Opal | Level 21

Thus, FriedEgg's code will work for that situation as well.  You really ought to give him credit for having answered the question.

raveena
Obsidian | Level 7

Yes Sure Art !! He resolved the problem for me with in few minutes !!!

Thanks FriedEgg !!!

art297
Opal | Level 21

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.

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

Register Now

What is Bayesian Analysis?

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 7 replies
  • 1669 views
  • 3 likes
  • 4 in conversation