Question

my data is of the following kind:

var1  var2  var3  var4
   1     0     1     0
   1     1     0     0
   0     0     0     1
...

I now want a frequency analysis over all var1 - var4 in the following way:

    Fancy Title
var1              2
var2              1
var3              1
var4              1

How can I achieve this in SPSS Syntax, thanks.

Was it helpful?

Solution

I agree with Christian Sauer in that if you have CTABLES this can probably be done the easiest with that command (I do not have that license though). But other possible ways are:

  • FREQUENCIES for Var1 TO Var4, specifying the sum for the columns. This table will come out in wide format, but you can edit it and transpose the columns and rows to get it in the format you want.
  • Use multiple response categories.
  • Reshape the data using VARSTOCASES so Var1 TO Var4 are now in one column. Then use CROSSTABS to get the table.

Examples of all three of these below. All three need to be edited post hoc to get the final table you want, but they are all pretty close.

data list free / Var1 to Var4 (4F1.0).
begin data
1 0 1 0
1 1 0 0
0 0 0 1
end data.

*Then Transpose the rows/columns and edit the table.
FREQ VAR Var1 TO Var4 /FORMAT = NOTABLE /STATISTICS = SUM.

*Use multiple respone categories.
MULT RESPONSE  GROUPS=$Var (Var1 Var2 Var3 Var4 (1))
  /FREQUENCIES=$Var  .

*Reshape and then use crosstabs.
VARSTOCASES /MAKE Var From Var1 to Var4 /INDEX Lab (Var).
CROSSTABS TABLE Lab BY Var.

OTHER TIPS

CTABLES would certain be the easiest solution, but doesn't simply using MULT RESPONSE do the job ?

MULT RESPONSE GROUPS=$myset (var1 var2 var3 var4 (1))
  /FREQUENCIES=$myset.

You can edit the table using the pivot table editor and delete or hide any columns you don't want.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top