Average from 2 lines in spss

I have the following data

pers.id       holiday
1                  0
1                  1
1                  0
1                  0
1                  1
1                  0
2                  0
2                  0
2                  1
2                  0
5                  0
5                  1
5                  0
9                  0
9                  0
9                  0
9                  0

Now I want to calculate the average percentage of holidays / work days. In this case, we have 4 people. The number of lines for each person .id is the number of days he worked. So if pers.id has 6 lines, it works 6 days. The holiday can be 0 or 1, whether this person had a holiday on this day or not. Now I want to calculate the average number of holidays / working days for all person.id

In the above example:

( 2/6 + 1/4 + 1/5 + 0/4) / 4

How to do this in SPSS syntax? I also need a confidence interval for this value.

+3
source share
1 answer

AGGREGATE . (. NABBLE, ), , , .

data list free / pers.id holiday.
begin data
1                  0
1                  1
1                  0
1                  0
1                  1
1                  0
2                  0
2                  0
2                  1
2                  0
5                  0
5                  1
5                  0
9                  0
9                  0
9                  0
9                  0
end data.

DATASET DECLARE AggProp.
AGGREGATE
  /OUTFILE = 'AggProp'
  /BREAK = pers.id
  /HolidayT=SUM(holiday)
  /HolidayP=MEAN(holiday)
  /NId=N.
+3

All Articles