Tips – find text and create dummy variables

 In Tips & Tricks

I got a question how to analyze text answers from a questionnaire, and if you don’t have any text mining programs you have to do the hard code work by yourself. And how do you use SPSS Statistics for that?

If you are just interested of some words then it’s quite ok to use SPSS Statistics, so in my example I want to know if people have answered “hotel” or something with “weather”, where also “sun” should be included. My tips is in the end to use syntax and save all commands!

In this small file you can see my text variable:

I start to create the dummy variable hotel, if the word “hotel” is found in the text variable and as you see it’s mentioned by several respondents:

You use the command: Transform – Compute

Then click on the “if”-button down to the left and then click “include if case satisfies condtion: ”

You will use the CHAR.INDEX-function and fill in following:

That means that the position in the text string for finding the text “hotel” should be bigger than 0 (so if SPSS cannot find this text it will be position=0).

Here is the result:

Next thing is to find something about “weather” and you can here use the OR between each condition. I also recommend to use both text “weather” and “Weather” as it’s sensitive for capital letters.

So here is the functions to use:

And here is the new variable:

So as you see, both “sun” and “sunny” will be coded with 1 (flag).

Now, make sure you save your compute commands into syntax. (start with the “Paste” button in dialog box).

Thanks for watching! /Gunilla

error: Content is protected !!