is there any way to pick "Y" from a variable with same id,
I have a id variable and flag variable with multiple observations
101 Y
101 N
101 N
102 N
102 N
103 Y
is there a way where we can pick 101 and only "Y" from it and ignore "N" and in second id only take one record "N" and omitt the duplicate.
Like this?
data have;
input id flag $;
datalines;
101 Y
101 N
101 N
102 N
102 N
103 Y
;
proc sort data=have;
by id flag;
run;
data want;
set have;
if last.id;
run;
If an ID has multiple Y flags what do you want for output? All N flags but more than 2 (your description does not actually cover this case as only mention similar for the second id. What if the 5th id has 4 flags?)
Best to provide an example of what the actual output should look like for given example input.
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!
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.