Example data and work through examples with actual values shown in your example data.
I am afraid that text like "and searches again it in Complaint, again if there’s a match and then again takes a value from Reason and searches it in Complaint column. After finding a match with all these 3 column values in Complaint column then what it should do is, it should concatenate all these 3 values into one single sentence and puts that value in the ExactReason " it is very hard to determine what may be needed with your exact values.
I am also not seeing clearly what is to be done if one one or two "matches" are found.
Note that you need to provide some rules and examples of the output. Since you are asking about multiple matches then ORDER of results might be an important bit and you need to provide rules for that as well.
Secondary not: almost any variable that holds two or more actual values is poor data design in general and likely should be reconsidered.
The request was
Example data and work through examples with actual values shown in your example data.
I see only one of the two data sets. I don't see where you have provided examples worked through so we can see what output you want.
Here's the example!. I apologize for not providing detailed info also for late response.
I've just given only one example but there are two thousand records of different complaints.
Data A; Input complaint $100. ExactReason $50.; Cards; DAMAGED / MISSING PART WATER LINE REPLACED BROKEN WATER LINE ; RUN; DATA B; REASON $50.; CARDS; DOORS & HANDLES : DOOR / DRAWER APPEARANCE / FINISH DEFECT : MISSING / WRONG PARTS ; RUN; Output; Complaint ExactReason DAMAGED / MISSING PART WATER LINE REPLACED BROKEN WATER LINE DOORS & HANDLES : DOOR / DRAWER APPEARANCE / FINISH DEFECT : MISSING / WRONG PARTS
Now, what I want is the value in Reason column of table B should be searched in the Complaint column of table A. If there's a match keep the value in Reason column in ExactReason column.
.
Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9.
Early bird rate extended! Save $200 when you sign up by March 31.
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.