Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Count Command Help

11 views
Skip to first unread message

Tess

unread,
Dec 23, 2009, 12:05:04 PM12/23/09
to
Hello,

I am working with a data set and I have a set of variables that range
from 0-4. I need to compute the number of variables that have been
given a 1-4. I am currently using a count command (see syntax pasted
below), which works great except that if a participant has all missing
values (user defined as 99 & 98) they still get a 0 instead of a
system missing value. So, I want my count command to only be executed
if the participant has at least 70% of the data entered. We went
compute means we accomplish this by using the following syntax:
COMPUTE ambsitratingpr = MEAN.13 (ambsit1apr, ambsit1bpr, ambsit1cpr,
ambsit1dpr, ambsit1epr, ambsit2apr, ambsit2bpr, ambsit2cpr,
ambsit2dpr, ambsit3apr, ambsit3bpr, ambsit3cpr, ambsit4apr,
ambsit4bpr, ambsit4cpr, ambsit5apr, ambsit5bpr, ambsit5cpr).

Here is my current syntax:
* Computing the FREQUENCY OF THREAT PERCEPTION
- the total number of sentences that the child identified as scary.

COUNT ambsitfreqpr=ambsit1apr ambsit1bpr ambsit1cpr ambsit1dpr
ambsit1epr ambsit2apr ambsit2bpr ambsit2cpr ambsit2dpr ambsit3apr
ambsit3bpr ambsit3cpr ambsit4apr ambsit4bpr ambsit4cpr ambsit4dpr
ambsit4epr ambsit5apr ambsit5bpr ambsit5cpr(1) ambsit1apr ambsit1bpr
ambsit1cpr ambsit1dpr ambsit1epr ambsit2apr ambsit2bpr ambsit2cpr
ambsit2dpr ambsit3apr ambsit3bpr ambsit3cpr ambsit4apr ambsit4bpr
ambsit4cpr ambsit4dpr ambsit4epr ambsit5apr ambsit5bpr ambsit5cpr(2)
ambsit1apr ambsit1bpr ambsit1cpr ambsit1dpr ambsit1epr ambsit2apr
ambsit2bpr ambsit2cpr ambsit2dpr ambsit3apr ambsit3bpr ambsit3cpr
ambsit4apr ambsit4bpr ambsit4cpr ambsit4dpr ambsit4epr ambsit5apr
ambsit5bpr ambsit5cpr(3) ambsit1apr ambsit1bpr ambsit1cpr ambsit1dpr
ambsit1epr ambsit2apr ambsit2bpr ambsit2cpr ambsit2dpr ambsit3apr
ambsit3bpr ambsit3cpr ambsit4apr ambsit4bpr ambsit4cpr ambsit4dpr
ambsit4epr ambsit5apr ambsit5bpr ambsit5cpr(4).
VARIABLE LABELS ambsitfreqpr 'Threat frequency total'.
EXECUTE.

I tried asking SPSS for help but they just told me what a COUNT
command does.

Any help would be greatly appreciated. Thanks!

JKPeck

unread,
Dec 23, 2009, 12:57:50 PM12/23/09
to

One way would be to enclose COUNT in a DO IF based on, say, mean.15.
DO IF (mean.15(A TO Z)).
COUNT ...
END IF.
where the number, 15, here, is whatever percentage you require to be
present in
the appropriate list of variables.

HTH,
Jon Peck

Tess

unread,
Dec 30, 2009, 4:48:23 PM12/30/09
to

Thanks Jon,

I actually kept getting an error #510 when I tried running my syntax
the way you suggested above so I must have misinterpreted something.
However, you did give me an idea and I ended up using a count of the
missing values to create a DO IF command, so it is working now. Thanks
for your input!

- Tess

JKPeck

unread,
Dec 30, 2009, 5:35:15 PM12/30/09
to

Glad you have this working, but my example should have been something
like
do if(not missing(mean.15(a to z))).
count...
end if.

If there are insufficient nonmissing values for mean.15, it is
returning sysmis, so wrapping that in a test for missing avoids the
problem

JKPeck

unread,
Dec 30, 2009, 5:50:29 PM12/30/09
to

I should also have pointed out that #510 is just a warning. You get
the correct result despite it.

Art Kendall

unread,
Dec 31, 2009, 6:09:53 PM12/31/09
to
One way would be to enclose COUNT in a DO IF based on, say, mean.15.
DO IF (mean.15(A TO Z)).
COUNT ...
END IF.
where the number, 15, here, is whatever percentage you require to be
present in
the appropriate list of variables.
The number 15 is the counted number of variables that must have valid values to perform the function, not a percentage.
mean.15(A TO Z)
will return a system missing value if there are fewer than 15 valid values.

You will get the same results but perhaps more readability with
DO IF NVALID(A TO Z) GE 15.
count ambsitfreqpr...
ELSE.
compute ambsitfreqpr = -1.
end if.
missing values ambsitfreqpr (-1).
value labels ambsitfreqpr -1 'not enough valid items to get score'.

This approach would also avoid having a system missing value when the user knows why the result is missing.

Art Kendall
Social Research Consultants
 

This approach

Art Kendall
0 new messages