I have a text string variable that has lots of categories. I'd like to create dummy variables from this and I am using regular expression.
response
ALLEGES, INJURED BY SOMEONE, UNDER INFLUENCE OF ALCOHOL
I have written regexm code like this.
gen alleges=regexm(response, "ALLEGES")
gen injury=regexm(response, "INJURED")
gen alcohol=regexm(response, "ALCOHOL")
But the code takes lots of lines for each set of words. I cannot use parse "," because the text strings are not in a specific order.
Is there a way to write a loop to same some time in writing each line by line?
response
ALLEGES, INJURED BY SOMEONE, UNDER INFLUENCE OF ALCOHOL
I have written regexm code like this.
gen alleges=regexm(response, "ALLEGES")
gen injury=regexm(response, "INJURED")
gen alcohol=regexm(response, "ALCOHOL")
But the code takes lots of lines for each set of words. I cannot use parse "," because the text strings are not in a specific order.
Is there a way to write a loop to same some time in writing each line by line?
Comment