Hi all - I have a string variable that has a list of various possible moods. I'm hoping to be able to work through that list and if a word on that list matches a variable name, code that variable 1 for that observation. I already generated the full list of variables using:
So, just could use some help with the next steps.
Here's the structure:
And here's what I'm trying to achieve:
Code:
levelsof update_pledge_mood1, local(moods) foreach l of local moods { gen `l' = . }
Here's the structure:
Code:
* Example generated by -dataex-. For more info, type help dataex clear input str15 update_pledge_mood1 float(angry annoyed appreciated content exhausted unmotivated) "content" . . . . . . "angry" . . . . . . "" . . . . . . "unmotivated" . . . . . . "exhausted" . . . . . . "content" . . . . . . "appreciated" . . . . . . end
Code:
* Example generated by -dataex-. For more info, type help dataex clear input str15 update_pledge_mood1 float(angry annoyed appreciated content exhausted unmotivated) "content" . . . 1 . . "angry" 1 . . . . . "" . . . . . . "unmotivated" . . . . . 1 "exhausted" . . . . 1 . "content" . . . 1 . . "appreciated" . . 1 . . . end
Comment