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.
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
Still thinking about your presentation idea? The submission deadline has been extended to Friday, Nov. 14, at 11:59 p.m. ET.
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.
Ready to level-up your skills? Choose your own adventure.