I have a list of terms that have spaces and quotes that I want to loop over. I have been able to loop over terms with spaces, I have also been able to loop over terms with quotes but never both spaces AND quotes together.
For instance, I have the expression: Today is "Sunday"
I have several expressions like this and I want a loop that will search this expression exactly "Today is "Sunday"", but spaces and loops are proving difficult. I find that I can read this expression properly into my loop but once I call on the local variable within the loop the text breaks down because of the quotes.
Here is an example
Code:
clear all set more off local expression `" "Today is "Sunday"" "' gen text=`"Today is "Sunday" and tomorrow is "Monday"' gen flag="" set trace on foreach term in `expression'{ replace flag=1 if strpos(text, `term' ) > 0 } tab flag
Any suggestions on how to loop over this expression fully?
thank you,
Donovan
0 Response to Loop with spaces and quotes
Post a Comment