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.

sas-innovate-2024.png

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.

 

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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