Hello all,
respondents to a survey indicated a list of names (fiction authors), and they were recorded in a single variable, separated by a comma.
Thus,
OBS | string |
1 | Toni Morrison |
2 | Kurt Vonnegut ,Harper Lee ,T.S. Eliot,Toni Morrison, Danielle Steel |
3 | Robert Ludlum ,James Patterson ,Tom Clancy ,Danielle Steel ,John Grisham |
I need to create a new variable (NEW) that has the frequency of CERTAIN authors. That is, the NEW should not simply count the number of words in STRING. For instance, I want NEW to count Morrison and Steel. So to obtain the following:
OBS | string | NEW |
1 | Toni Morrison | 1 |
2 | Kurt Vonnegut ,Harper Lee ,T.S. Eliot,Toni Morrison, Danielle Steel | 2 |
3 | Robert Ludlum ,James Patterson ,Tom Clancy ,Danielle Steel ,John Grisham | 1 |
I am having troubles finding a solution.
Any suggestion would be greatly appreciated
Eman