Hi,
I am trying to program in Stata 14.2 so that if a cell (string variable) starts with a certain word or phrase, it should be marked as 1
I've tried the following:
generate STUFF=0
replace STUFF=1 if strpos(stringvariable, "stuff")
However, this just marks it as 1 if stuff is contained in the string; fx if it says "nice stuff", whereas I need it to only be 1 if it says "stuff that is nice", e.g. the phrase STARTS with stuff.
Is this possible in Stata?
I hope the questions makes sense
Thanks, all the best,
Line
I am trying to program in Stata 14.2 so that if a cell (string variable) starts with a certain word or phrase, it should be marked as 1
I've tried the following:
generate STUFF=0
replace STUFF=1 if strpos(stringvariable, "stuff")
However, this just marks it as 1 if stuff is contained in the string; fx if it says "nice stuff", whereas I need it to only be 1 if it says "stuff that is nice", e.g. the phrase STARTS with stuff.
Is this possible in Stata?
I hope the questions makes sense
Thanks, all the best,
Line
Comment