I have a program with a list of strings delimited by "|" that I want to look up in a string variable column. I'm getting some odd behavior that I don't understand. Below is a code example: data birds;
/* list of words */
all_the_words = 'BIRD|DOG|CAT';
length word_from_list $100.;
/* pull the first word from all_the_words */
do i = 1 to 1;
word_from_list = strip(scan(all_the_words, i, '|'));
end;
put "word_from_list: " word_from_list;
/* assert that word_from_list is the same */
words_the_same = (word_from_list = "BIRD");
/* text in which we look up BIRD */
text_for_lookup = "BIRD (text here)";
/* find results for word_from_list */
found_it = find(text_for_lookup, word_from_list);
/* find results for literal "BIRD" */
found_it_2 = find(text_for_lookup, "BIRD");
run; I'm finding that despite words_the_same being 1, I'm getting different results for found_it and found_it_2. Attached is the output dataset from this code run. I'm curious why these give different results and how to make it so that word_from_list gets found.
... View more