SPSS Tips & Tricks #12 – Syntax of compute

 In Tips & Tricks

Last week I introduced you to syntax, and today I will continue with syntax.

In the blog made 6 Aug, I showed the compute command that create a calculated index – the mean value for several variables per each case. So I will show you how to create a syntax from this command and rebuild it, by changing and writing syntax text.

First I use to start with the command from the menus (to save time), in this example
Transform – Compute:

After the command is ready with target variable name and the numeric expression (see above) click on the “Paste”-button instead of “OK”:

Then you get this syntax in the syntax window:

You can now copy the whole COMPUTE – command row.

And paste in so many times as the number of new variables you want to calculate, in my cases 4:

Start typing directly into the text, or you can also “paste” in the variable names if you use the “Variable window” that you can find in the tool bar:

I type in the new target variables like “afraid_driver”, “tech_driver” and so on. I also type in the variable names within the parentheses (v250,v244..  and so on) directly into the syntax in the example below.

If something goes wrong in the syntax you will see that clearly:

In the end you mark the text and run the command.

The EXECUTE-command is needed to actually run all COMPUTE-rows.

Here is the result, in the end of the data file I can find the 4 new index variables:

Thanks for watching!

Gunilla Rudander

error: Content is protected !!