Date: Thu, 29 Jul 1999 13:47:09 +0200
Reply-To: Rolf Kjoeller <rolf.kjoeller@GET2NET.DK>
Sender: "SPSSX(r) Discussion" <SPSSX-L@LISTSERV.UGA.EDU>
From: Rolf Kjoeller <rolf.kjoeller@GET2NET.DK>
Subject: Sv: Repeating compute statements
Content-Type: text/plain; charset="iso-8859-1"
Oops, you *will* get errors - the "aggregate" and "match file"-statements should be:
compute dummy = 1.
aggregate outfile='agg.sav' /break=dummy /m_q1 to m_q74=mean(q1 to q74) .
match files file=* /TABLE="agg.sav" /by dummy /drop dummy .
execute .
sorry about that.
Rolf
----- Oprindelig meddelelse -----
Fra: Rolf Kjoeller <rolf.kjoeller@get2net.dk>
Til: SPSSX-L <SPSSX-L@listserv.uga.edu>; Grant <grant@ASKAFRIKA.CO.ZA>
Sendt: 29. juli 1999 10:50
Emne: Sv: Repeating compute statements
Hi Grant.
You can use the "do repeat"-command:
do repeat var=q1 to q74 .
COMPUTE var = (mean(var)/5)*100.
end repeat .
EXECUTE .
But is this what you want? For each case the mean of "var" will just be the value of "var", so you are just rescaling "var" when you divide the values with 5 and multiply with 100. If instead you want the rescaled mean-score of all 74 variables, then this should do (I think the "to"-keyword can be used but haven't tested):
COMPUTE mscore = (mean.20(q1 to q74)/5)*100 .
execute .
The mean.20 indicates that I want to base the mean on at least 20 values; if there are less than 20 valid values, the mean isn't calculated. Adjust or omit to your needs.
If instead you want the mean of "var" ACROSS the cases, you should use "aggregate"; something like
compute dummy = 1.
aggregate outfile=* /break=dummy /(m_q1 to m_q74)=mean(q1 to q74) .
- afterwards you could use the do repeat-stuff above to rescale. Also, the results could be merged onto the raw cases using "aggregate" and "match files":
compute dummy = 1.
aggregate outfile="agg.sav" /break=dummy /(m_q1 to m_q74)=mean(q1 to q74) .
match files file=* /file="agg.sav" /by dummy .
(If you get errors, check with the syntaxmanual; I haven't run any of this.)
HTH
Rolf
----- Oprindelig meddelelse -----
Fra: Grant <grant@ASKAFRIKA.CO.ZA>
Nyhedsgrupper: bit.listserv.spssx-l
Til: <SPSSX-L@LISTSERV.UGA.EDU>
Sendt: 29. juli 1999 09:48
Emne: Repeating compute statements
> Hello all,
>
> Sorry about the basic question! I need to repeat the following compute
> statement 74 times, is there a way that I can do it quicker than doing each
> statement separately. The questions range from q1 to q74. I've tried
> various ways but with no success.
>
> COMPUTE q1 = (mean(q1)/5)*100.
> EXECUTE .
>
> Thanks in advance
>
> Grant Robertson
> Ask Afrika
>