I'm wondering if anyone can help me out with this issue. I'm trying to
create a new variable, by adding together five of the existing ones. The problem is that some of the existing variables contain missing values. I'm wondering if there's any way to let SPSS know to skip the missing values and add up all the other values. I know there's a command DO IF MISSING, but it seems you would have to specify - do if missing v1, do if missing v2, etc, etc. Is there an easier way to do this? any advice would be greatly appreciated. Alina Sheyman, Family Office Exchange |
I may be misunderstanding what you are trying to do, but if it is summation
of the variables and you want to skip missing variables, then why not replace missing values with zeros, it's not going to affect the sum? Dan >From: Alina Sheyman <[hidden email]> >Reply-To: Alina Sheyman <[hidden email]> >To: [hidden email] >Subject: Computing with missing values >Date: Wed, 18 Oct 2006 11:09:46 -0400 > >I'm wondering if anyone can help me out with this issue. I'm trying to >create a new variable, by adding together five of the existing ones. The >problem is that some of the existing variables contain missing values. I'm >wondering if there's any way to let SPSS know to skip the missing values >and add up all the other values. >I know there's a command DO IF MISSING, but it seems you would have to >specify - do if missing v1, do if missing v2, etc, etc. Is there an easier >way to do this? >any advice would be greatly appreciated. > >Alina Sheyman, Family Office Exchange _________________________________________________________________ All-in-one security and maintenance for your PC. Get a free 90-day trial! http://clk.atdmt.com/MSN/go/msnnkwlo0050000002msn/direct/01/?href=http://www.windowsonecare.com/?sc_cid=msn_hotmail |
In reply to this post by Alina Sheyman
Or even better, use SUM function:
Compute mysum = sum(v1 to v2). Missings will be skipped automatically. HTH Jan -----Original Message----- From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Dan Zetu Sent: Wednesday, October 18, 2006 5:14 PM To: [hidden email] Subject: Re: Computing with missing values I may be misunderstanding what you are trying to do, but if it is summation of the variables and you want to skip missing variables, then why not replace missing values with zeros, it's not going to affect the sum? Dan >From: Alina Sheyman <[hidden email]> >Reply-To: Alina Sheyman <[hidden email]> >To: [hidden email] >Subject: Computing with missing values >Date: Wed, 18 Oct 2006 11:09:46 -0400 > >I'm wondering if anyone can help me out with this issue. I'm trying to >create a new variable, by adding together five of the existing ones. >The problem is that some of the existing variables contain missing >values. I'm wondering if there's any way to let SPSS know to skip the >missing values and add up all the other values. >I know there's a command DO IF MISSING, but it seems you would have to >specify - do if missing v1, do if missing v2, etc, etc. Is there an >easier way to do this? >any advice would be greatly appreciated. > >Alina Sheyman, Family Office Exchange _________________________________________________________________ All-in-one security and maintenance for your PC. Get a free 90-day trial! http://clk.atdmt.com/MSN/go/msnnkwlo0050000002msn/direct/01/?href=http:/ /www.windowsonecare.com/?sc_cid=msn_hotmail |
To expand even further on Jan's comment.
*this will compute a variable called NEWVAR if 1 or more items have valid (nonmissing) data . compute NEWVAR=sum.1(x1,x2,x3,x4) . list var=newvar x1 x2 x3 x4 . *this will compute a variable called NEWVAR2 only if 4 items have valid (nonmissing) data . compute NEWVAR2=sum.4(x1,x2,x3,x4) . list var=newvar2 x1 x2 x3 x4 . > -----Original Message----- > From: SPSSX(r) Discussion [mailto:[hidden email]] > On Behalf Of Spousta Jan > Sent: Wednesday, October 18, 2006 11:17 AM > To: [hidden email] > Subject: Re: Computing with missing values > > > Or even better, use SUM function: > > Compute mysum = sum(v1 to v2). > > Missings will be skipped automatically. > > HTH > > Jan > > -----Original Message----- > From: SPSSX(r) Discussion [mailto:[hidden email]] > On Behalf Of Dan Zetu > Sent: Wednesday, October 18, 2006 5:14 PM > To: [hidden email] > Subject: Re: Computing with missing values > > I may be misunderstanding what you are trying to do, but if > it is summation of the variables and you want to skip missing > variables, then why not replace missing values with zeros, > it's not going to affect the sum? > > Dan > > >From: Alina Sheyman <[hidden email]> > >Reply-To: Alina Sheyman <[hidden email]> > >To: [hidden email] > >Subject: Computing with missing values > >Date: Wed, 18 Oct 2006 11:09:46 -0400 > > > >I'm wondering if anyone can help me out with this issue. I'm > trying to > >create a new variable, by adding together five of the > existing ones. > >The problem is that some of the existing variables contain missing > >values. I'm wondering if there's any way to let SPSS know to > skip the > >missing values and add up all the other values. I know there's a > >command DO IF MISSING, but it seems you would have to > specify - do if > >missing v1, do if missing v2, etc, etc. Is there an easier way to do > >this? any advice would be greatly appreciated. > > > >Alina Sheyman, Family Office Exchange > > _________________________________________________________________ > All-in-one security and maintenance for your PC. Get a free > 90-day trial! > http://clk.atdmt.com/MSN/go/msnnkwlo0050000002msn/direct/01/?h /www.windowsonecare.com/?sc_cid=msn_hotmail |
In reply to this post by Alina Sheyman
For a number of reason I was actually trying to avoid replacing missing
values. |
In reply to this post by Alina Sheyman
Great, thanks a bunch!
|
In reply to this post by Alina Sheyman
many within case transformation functions can have a suffix to the
function name that specifies a minimum number of valid values that occur in the list of values that are the argument list. e.g. compute score1 =mean.3(v1 to v5). compute score2 =sum.1(v1 to v5). compute score3 =sum.5(v1, v19, v22, v27, v101, v104, v115). etc. Be careful about the meaning of a result especially of the sum function if some items are missing. Art Kendall Social Research Consultants Alina Sheyman wrote: >I'm wondering if anyone can help me out with this issue. I'm trying to >create a new variable, by adding together five of the existing ones. The >problem is that some of the existing variables contain missing values. I'm >wondering if there's any way to let SPSS know to skip the missing values >and add up all the other values. >I know there's a command DO IF MISSING, but it seems you would have to >specify - do if missing v1, do if missing v2, etc, etc. Is there an easier >way to do this? >any advice would be greatly appreciated. > >Alina Sheyman, Family Office Exchange > > > >
Art Kendall
Social Research Consultants |
In reply to this post by Alina Sheyman
The SUM function in compute will skip missing values, while addition
(using "+") returns sysmis if one or more of the variables is missing: **gives a value if any of var1 to var5 is non-missing. COMPUTE tot_score = sum(var1,var2,var3,var4,var5 ). ** gives SYSMIS is any of var1 to var5 is missing. COMPUTE tot_score = var1+var2+var3+var4+var5. You can also control the number of valid values required: COMPUTE tot_score = sum.2(var1,var2,var3,var4,var5 ). (the sum.2 means compute the total if two or more values are non-missing. You can also calculate the average directly, controlling for number of valid values: COMPUTE avg_score = mean.3 (var1,var2,var3,var4,var5 ). (the mean.3 requires three or more non-missing values before a mean is computed.) --cheers Jim -----Original Message----- From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Dan Zetu Sent: Wednesday, October 18, 2006 10:14 AM To: [hidden email] Subject: Re: Computing with missing values I may be misunderstanding what you are trying to do, but if it is summation of the variables and you want to skip missing variables, then why not replace missing values with zeros, it's not going to affect the sum? Dan >From: Alina Sheyman <[hidden email]> >Reply-To: Alina Sheyman <[hidden email]> >To: [hidden email] >Subject: Computing with missing values >Date: Wed, 18 Oct 2006 11:09:46 -0400 > >I'm wondering if anyone can help me out with this issue. I'm trying to >create a new variable, by adding together five of the existing ones. >The problem is that some of the existing variables contain missing >values. I'm wondering if there's any way to let SPSS know to skip the >missing values and add up all the other values. >I know there's a command DO IF MISSING, but it seems you would have to >specify - do if missing v1, do if missing v2, etc, etc. Is there an >easier way to do this? >any advice would be greatly appreciated. > >Alina Sheyman, Family Office Exchange _________________________________________________________________ All-in-one security and maintenance for your PC. Get a free 90-day trial! http://clk.atdmt.com/MSN/go/msnnkwlo0050000002msn/direct/01/?href=http:/ /www.windowsonecare.com/?sc_cid=msn_hotmail |
In reply to this post by Spousta Jan
I might be wrong but sum(v1 to v2) will get a sum for each respondent if
the respondent has at least one valid response (default is sum.1). If you want to sum all valid than you would have to use sum.2 to get both valid responses added. martin sherman >>> Spousta Jan <[hidden email]> 10/18/2006 11:16:32 AM >>> Or even better, use SUM function: Compute mysum = sum(v1 to v2). Missings will be skipped automatically. HTH Jan -----Original Message----- From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Dan Zetu Sent: Wednesday, October 18, 2006 5:14 PM To: [hidden email] Subject: Re: Computing with missing values I may be misunderstanding what you are trying to do, but if it is summation of the variables and you want to skip missing variables, then why not replace missing values with zeros, it's not going to affect the sum? Dan >From: Alina Sheyman <[hidden email]> >Reply-To: Alina Sheyman <[hidden email]> >To: [hidden email] >Subject: Computing with missing values >Date: Wed, 18 Oct 2006 11:09:46 -0400 > >I'm wondering if anyone can help me out with this issue. I'm trying to >create a new variable, by adding together five of the existing ones. >The problem is that some of the existing variables contain missing >values. I'm wondering if there's any way to let SPSS know to skip the >missing values and add up all the other values. >I know there's a command DO IF MISSING, but it seems you would have to >specify - do if missing v1, do if missing v2, etc, etc. Is there an >easier way to do this? >any advice would be greatly appreciated. > >Alina Sheyman, Family Office Exchange _________________________________________________________________ All-in-one security and maintenance for your PC. Get a free 90-day trial! http://clk.atdmt.com/MSN/go/msnnkwlo0050000002msn/direct/01/?href=http:/ /www.windowsonecare.com/?sc_cid=msn_hotmail |
In reply to this post by Alina Sheyman
At 11:23 AM 10/18/2006, Alina Sheyman wrote:
>For a number of reason I was actually trying to avoid replacing >missing >values. Very wise. Confusing data that isn't there, and data whose value is 0, is a recipe for madness. As multiple others have said, and you know, "SUM(...)" is exactly what you want. |
Free forum by Nabble | Edit this page |