Consider the dataset
Data Exam;
format exam_date date9.;
informat exam_date date9.;
Input ID $ exam_date Test1 $;
Datalines;
9000001 01JAN2023 A,B
9000001 15FEB2023 D,B
9000001 20MAR2023 E,C
9000003 15FEB2023 D,B
9000003 20MAR2023 F,C
9000004 20MAR2023 B
9000004 20MAR2023 G
answer1 condition if patient containing A, B, C then only those should in final dataset
my answer1 should be
9000001 A+B+C
9000003 B+C
9000004 B
answer2 condition if patient containing other then A, B, C then only those should in final dataset
my answer2 should be
9000001 D+E
9000003 D+F
9000004 G
please write a code that will help to achieve this result
Looks like some kind of homework or exam. What have you tried so far?
There are many ways to create the datasets you need. But i don't think that posting a solution will help you to solve tasks in the future. So, what have you tried?
Hi,
As others have said, sharing what you have tried will help both you and us. I would also advise sharing the log if you have run the code, including any notes, warnings, or error messages.
Please use the Insert Code icon "</>" when posting code or log content.
Thanks & kind regards,
Amir.
How I would approach it:
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.