* I have a scale with 47 items, with responses of 0 or 1. Each item has a
different weight, ranging from 9.16 to 13.51. Each weight is then
multiplied by 0 or 1, depending on the response. The resulting total of
these products is divided by the grand total of all the possible weights
(544.76) to compute a percentage score.
*My question concerns how to adjust the grand total of the weights when one
or more of the responses is missing. For example, if a case is missing an
item with a weight of 11.55, I want to subtract this weight from 544.76, so
that the grand total of all possible weights for this case is 533.21. If
two items are missing, I want to subtract both of their weights from 544.76.
*I would like to write syntax that would determine which items are missing
for each case and subtract the corresponding weight(s) from the grand total
in some kind of automated manner. Any suggestions would be welcome.
* This answer was posted on 2000/10/23 by Raynald Levesque to SPSSX-L.
DATA LIST LIST /s1 TO s3 w1 TO w3.
BEGIN DATA
1 1 1
0 1 0
. 1 .
0 0 0
1 1 0
END DATA.
LIST.
* Assign the weighs.
COMPUTE w1=9.
COMPUTE w2=11.
COMPUTE w3=10.
*Check which scores exist.
VECTOR s=s1 TO s3.
VECTOR exist(3F1.0).
LOOP #cnt=1 TO 3.
COMPUTE exist(#cnt)=~SYSMIS(s(#cnt)).
END LOOP.
*Calculate maximum weight of scores which exists.
VECTOR w=w1 TO w3.
VECTOR maxw(3F3.2).
LOOP #cnt=1 TO 3.
COMPUTE maxw(#cnt)=w(#cnt)*exist(#cnt).
END LOOP.
*Calculate actual score.
VECTOR score(3F3.2).
LOOP #cnt=1 TO 3.
COMPUTE score(#cnt)=s(#cnt)*w(#cnt).
END LOOP.
*Calculate average percentage score.
COMPUTE pcscore=SUM(score1 TO score3)/SUM(maxw1 TO maxw3).
EXECUTE.