BookmarkSubscribeRSS Feed
msharma1788
Calcite | Level 5

Dataset
ssn Amt PLAN Mod
2345 233 9229 26
2345 244 9222 12
1234 222 9229 26

Expected result
ssn Amt PLAN Mod
2345 233 9229 26
1234 222 9229 26

I need to keep only one row for this ppt if it has row for both the plans (9229,9222) . I need to just poulate row for plan 9229. How can this be done with out dropping any variable.

1 REPLY 1
Kurt_Bremser
Super User

Double DO loop

data want;
do until (last.ssn);
  set have;
  by ssn notsorted;
  if plan = "9222" then has_9222 = 1;
end;
do until (last.ssn);
  set have;
  by ssn notsorted;
  if plan = "9229" and has_9222 then output;
end;
drop has_9222;
run;

Untested, for lack of usable data.

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

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
  • 1 reply
  • 313 views
  • 0 likes
  • 2 in conversation