Hi. I have two datasets both with string variables. The first one has a variable CountryName with names of countries for each observation. The second has a variable EventDetails which has mentions of countries along with other information for each observation. From the string for each observation in EventDetails in the second dataset, I want to parse out the country name only if it was in the variable CountryName in the first dataset. Merging the two datasets is not an option here for multiple reasons. Is there anyway for me to use the commands levelsof, locals and a loop to do this across datasets? Or possibly any other way to do this other than making a list of all the country names under the CountryName variable from the first dataset?

Thank you.