|
Hi,
I would like to compute a new variable which is the mean of different variables. the new variable is called RespSelf1. The mean has to be calculated from these groups of variables: response.1 to response.5 response.51 to response.55 response.101 to response.105 response.151 to response.155 response.201 to response.205 How to write this down in the syntax? I have tried: COMPUTE RespSelf1 = mean((response.1 to response.5), (response.51 to 55) ). and COMPUTE RespSelf1 = mean(response.1 to response.5, response.51 to 55 ). Neither of them worked. Does anyone know how to do this? Thanks a lot! ===================== To manage your subscription to SPSSX-L, send a message to [hidden email] (not to SPSSX-L), with no body text except the command. To leave the list, send the command SIGNOFF SPSSX-L For a list of commands to manage subscriptions, send the command INFO REFCARD |
|
Administrator
|
This is not terribly elegant, but will work, I think. compute #sum = sum(response.1 to response.5) + sum(response.51 to response.55) + sum(response.101 to response.105) + sum(response.151 to response.155) + sum(response.201 to response.205) . compute #n = nvalid(response.1 to response.5) + nvalid(response.51 to response.55) + nvalid(response.101 to response.105) + nvalid(response.151 to response.155) + nvalid(response.201 to response.205) . compute RespSelf1 = #sum/#n. exe.
--
Bruce Weaver bweaver@lakeheadu.ca http://sites.google.com/a/lakeheadu.ca/bweaver/ "When all else fails, RTFM." PLEASE NOTE THE FOLLOWING: 1. My Hotmail account is not monitored regularly. To send me an e-mail, please use the address shown above. 2. The SPSSX Discussion forum on Nabble is no longer linked to the SPSSX-L listserv administered by UGA (https://listserv.uga.edu/). |
|
In reply to this post by Shanti Ganesh
Shanti Ganesh wrote:
This should work: COMPUTE RespSelf1 = mean(response.1 to response.5, response.51 to response.55, response.101 to response.105, response.151 to response.155, response.201 to response.205). Notice that you forgot to add "response." when you wrote "response.51 to 55" just before "55". HTH, Marta GG > I would like to compute a new variable which is the mean of different > variables. > > the new variable is called RespSelf1. > > The mean has to be calculated from these groups of variables: > > response.1 to response.5 > response.51 to response.55 > response.101 to response.105 > response.151 to response.155 > response.201 to response.205 > > How to write this down in the syntax? > > I have tried: > > COMPUTE RespSelf1 = mean((response.1 to response.5), (response.51 to 55) ). > > and > > COMPUTE RespSelf1 = mean(response.1 to response.5, response.51 to 55 ). > > Neither of them worked. > > Does anyone know how to do this? > > Thanks a lot! > > ===================== > To manage your subscription to SPSSX-L, send a message to > [hidden email] (not to SPSSX-L), with no body text except the > command. To leave the list, send the command > SIGNOFF SPSSX-L > For a list of commands to manage subscriptions, send the command > INFO REFCARD > > -- For miscellaneous SPSS related statistical stuff, visit: http://gjyp.nl/marta/ ===================== To manage your subscription to SPSSX-L, send a message to [hidden email] (not to SPSSX-L), with no body text except the command. To leave the list, send the command SIGNOFF SPSSX-L For a list of commands to manage subscriptions, send the command INFO REFCARD |
|
In reply to this post by Shanti Ganesh
>Notice that you forgot to add "response." when you wrote "response.51 to
>55" just before "55". > >HTH, >Marta GG > Thanks Marta for pointing out the mistake! *multi-embarassed* Glad it works this way. Thank you also Bruce and Andrew for the sum and nvalid tips. It works too! best, Shanti ===================== To manage your subscription to SPSSX-L, send a message to [hidden email] (not to SPSSX-L), with no body text except the command. To leave the list, send the command SIGNOFF SPSSX-L For a list of commands to manage subscriptions, send the command INFO REFCARD |
| Free forum by Nabble | Edit this page |
