I am trying to sum up a series of likert scores to create a new variable but need to excluded any that were answered "Chose not to answer" which were coded 99. How would I use the transform/compute variable function? These are my variables: Sum (CP_EX_1,CP_EX_2,CP_EX_3,CP_IN_1,CP_IN_2,CP_IN_3,CP_RE_1,CP_RE_2,CP_RE_3,CP_TR_1,CP_TR_2,CP_TR_3) My if statement seems to be the problem. I thought that I could "or" to create a set.... if (CP_EX_1 | CP_EX_2 | CP_EX_3 | CP_IN_1 | CP_IN_2 | CP_IN_3 | CP_RE_1 | CP_RE_2 | CP_RE_3 | CP_TR_1 | CP_TR_2 | CP_TR_3) ~= 99 Is there a better way to do this? S. Hayes Empire State College |
Suzanne,
You should have 99 set as a missing value for all
variables to which it applies.
Gene Maguin From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Suzanne Hayes Sent: Friday, June 24, 2011 3:09 PM To: [hidden email] Subject: Need help excluding a value when computing a variable I am trying to sum up a series of likert scores to create a new variable but need to excluded any that were answered "Chose not to answer" which were coded 99. How would I use the transform/compute variable function? These are my variables: Sum (CP_EX_1,CP_EX_2,CP_EX_3,CP_IN_1,CP_IN_2,CP_IN_3,CP_RE_1,CP_RE_2,CP_RE_3,CP_TR_1,CP_TR_2,CP_TR_3) My if statement seems to be the problem. I thought that I could "or" to create a set.... if (CP_EX_1 | CP_EX_2 | CP_EX_3 | CP_IN_1 | CP_IN_2 | CP_IN_3 | CP_RE_1 | CP_RE_2 | CP_RE_3 | CP_TR_1 | CP_TR_2 | CP_TR_3) ~= 99 Is there a better way to do this? S. Hayes Empire State College |
In reply to this post by Suzanne Hayes
I would not use a sum if you have missing data as the missingness will be related to the sum. What you do depends on why the data is missing. Imputation is one solution. Using a mean instead of a sum is another although that is more likely to bias results if the missing is not missing completely at random. Dr. Paul R. Swank, Professor Children's Learning Institute University of Texas Health Science Center-Houston From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Suzanne Hayes
|
In reply to this post by Maguin, Eugene
To elaborate further.
missing values <all your variables> (99). compute sum = sum(x,y,z etc). will do it. If you run something like compute xory = x|y. you will see that this doesn't make sense if the variables are not true/false (1,0). Jon Peck Senior Software Engineer, IBM [hidden email] new phone: 720-342-5621 From: Gene Maguin <[hidden email]> To: [hidden email] Date: 06/24/2011 01:21 PM Subject: Re: [SPSSX-L] Need help excluding a value when computing a variable Sent by: "SPSSX(r) Discussion" <[hidden email]> Suzanne, You should have 99 set as a missing value for all variables to which it applies. Gene Maguin From: SPSSX(r) Discussion [[hidden email]] On Behalf Of Suzanne Hayes Sent: Friday, June 24, 2011 3:09 PM To: [hidden email] Subject: Need help excluding a value when computing a variable I am trying to sum up a series of likert scores to create a new variable but need to excluded any that were answered "Chose not to answer" which were coded 99. How would I use the transform/compute variable function? These are my variables: Sum (CP_EX_1,CP_EX_2,CP_EX_3,CP_IN_1,CP_IN_2,CP_IN_3,CP_RE_1,CP_RE_2,CP_RE_3,CP_TR_1,CP_TR_2,CP_TR_3) My if statement seems to be the problem. I thought that I could "or" to create a set.... if (CP_EX_1 | CP_EX_2 | CP_EX_3 | CP_IN_1 | CP_IN_2 | CP_IN_3 | CP_RE_1 | CP_RE_2 | CP_RE_3 | CP_TR_1 | CP_TR_2 | CP_TR_3) ~= 99 Is there a better way to do this? S. Hayes Empire State College |
In reply to this post by Suzanne Hayes
At 03:09 PM 6/24/2011, Suzanne Hayes wrote:
>I am trying to sum up a series of likert scores to create a new >variable but need to excluded any that were answered "Chose not to >answer" which were coded 99. > >How would I use the transform/compute variable function? > >These are my variables: > >Sum (CP_EX_1,CP_EX_2,CP_EX_3,CP_IN_1,CP_IN_2,CP_IN_3, > CP_RE_1,CP_RE_2,CP_RE_3,CP_TR_1,CP_TR_2,CP_TR_3) It sounds like you want MISSING VALUES CP_EX_1 TO CP_TR_3 (99). before the SUM. If the variables aren't contiguous in the file, you'll have to give the whole list in the MISSING VALUES statement: MISSING VALUES CP_EX_1 CP_EX_2 CP_EX_3 CP_IN_1 CP_IN_2 CP_IN_3 CP_RE_1 CP_RE_2 CP_RE_3 CP_TR_1 CP_TR_2 CP_TR_3 (99). ===================== 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
|
In reply to this post by Suzanne Hayes
Suzanne,
Really need more info. Several possible interpretations here: 1. Are you trying to compute this scale ONLY for cases in which there are NO 99's -missing- for any variable? 2. Are you attempting to compute a SUM over items but NOT include those items with 99 in the sum? ---- Your attempt here: if (CP_EX_1 | CP_EX_2 | CP_EX_3 | CP_IN_1 | CP_IN_2 | CP_IN_3 | CP_RE_1 | CP_RE_2 | CP_RE_3 | CP_TR_1 | CP_TR_2 | CP_TR_3) ~= 99 would suggest option 1. Basic rewrite: *N.B. Cases with ANY missing values will have System Missing on NewVar!. DO IF NOT(any(99, CP_EX_1 , CP_EX_2 , CP_EX_3 , CP_IN_1 , CP_IN_2 , CP_IN_3, CP_RE_1, CP_RE_2 , CP_RE_3 , CP_TR_1 , CP_TR_2 , CP_TR_3) ). + COMPUTE newvar=SUM(CP_EX_1 , CP_EX_2 , CP_EX_3 , CP_IN_1 , CP_IN_2 , CP_IN_3, CP_RE_1, CP_RE_2 , CP_RE_3 , CP_TR_1 , CP_TR_2 , CP_TR_3). END IF. Of the variables are contiguous in the file then the following is preferred: DO IF NOT(ANY(99, CP_EX_1 TO CP_TR_3) ). + COMPUTE newvar=SUM(CP_EX_1 TO CP_TR_3). END IF. OTOH, if you HAVE declared these variables as having missing values (99) then that will fail. ie MISSING VALUES CP_EX_1 TO CP_TR_3 (99). However using VALUE() function will peak under the covers so to speak. DO IF NOT(ANY(VALUE(99), CP_EX_1 TO CP_TR_3) ). + COMPUTE newvar=SUM(CP_EX_1 TO CP_TR_3). END IF. If Option 2. then simply . MISSING VALUES CP_EX_1 TO CP_TR_3 (99). COMPUTE newvar=SUM(CP_EX_1 TO CP_TR_3). will suffice but as others have commented, the total value is related to the "missingness", but maybe that's what you want.
Please reply to the list and not to my personal email.
Those desiring my consulting or training services please feel free to email me. --- "Nolite dare sanctum canibus neque mittatis margaritas vestras ante porcos ne forte conculcent eas pedibus suis." Cum es damnatorum possederunt porcos iens ut salire off sanguinum cliff in abyssum?" |
There's a set of tutorials on page "3.5 Derived variables (COUNT and COMPUTE)" of my website which covers summing Likert type scales (including reversing codes if necessary) with fully worked examples.
http://surveyresearch.weebly.com/block-3-analysing-two-variables-and-sometimes-three.html You can also check how many items are missing by: COUNT x = <varlist> (99). FREQ x . . . where <varlist> can be all 12 in your list or, judging by your varnames, separate sets of 3. If your items are coded eg 1 - 5, and you're adding them together to form a scale, it's sometimes advisable to create a zero point by subtracting the number of items summed. John F Hall [hidden email] www.surveyresearch.weebly.com -----Original Message----- From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of David Marso Sent: 24 June 2011 23:18 To: [hidden email] Subject: Re: Need help excluding a value when computing a variable Suzanne, Really need more info. Several possible interpretations here: 1. Are you trying to compute this scale ONLY for cases in which there are NO 99's -missing- for any variable? 2. Are you attempting to compute a SUM over items but NOT include those items with 99 in the sum? ---- Your attempt here: if (CP_EX_1 | CP_EX_2 | CP_EX_3 | CP_IN_1 | CP_IN_2 | CP_IN_3 | CP_RE_1 | CP_RE_2 | CP_RE_3 | CP_TR_1 | CP_TR_2 | CP_TR_3) ~= 99 would suggest option 1. Basic rewrite: *N.B. Cases with ANY missing values will have System Missing on NewVar!. DO IF NOT(any(99, CP_EX_1 , CP_EX_2 , CP_EX_3 , CP_IN_1 , CP_IN_2 , CP_IN_3, CP_RE_1, CP_RE_2 , CP_RE_3 , CP_TR_1 , CP_TR_2 , CP_TR_3) ). + COMPUTE newvar=SUM(CP_EX_1 , CP_EX_2 , CP_EX_3 , CP_IN_1 , CP_IN_2 , CP_IN_3, CP_RE_1, CP_RE_2 , CP_RE_3 , CP_TR_1 , CP_TR_2 , CP_TR_3). END IF. Of the variables are contiguous in the file then the following is preferred: DO IF NOT(ANY(99, CP_EX_1 TO CP_TR_3) ). + COMPUTE newvar=SUM(CP_EX_1 TO CP_TR_3). END IF. OTOH, if you HAVE declared these variables as having missing values (99) then that will fail. ie MISSING VALUES CP_EX_1 TO CP_TR_3 (99). However using VALUE() function will peak under the covers so to speak. DO IF NOT(ANY(VALUE(99), CP_EX_1 TO CP_TR_3) ). + COMPUTE newvar=SUM(CP_EX_1 TO CP_TR_3). END IF. If Option 2. then simply . MISSING VALUES CP_EX_1 TO CP_TR_3 (99). COMPUTE newvar=SUM(CP_EX_1 TO CP_TR_3). will suffice but as others have commented, the total value is related to the "missingness", but maybe that's what you want. Suzanne Hayes wrote: > > I am trying to sum up a series of likert scores to create a new variable > but need to excluded any that were answered "Chose not to answer" which > were coded 99. > > How would I use the transform/compute variable function?� � > > These are my variables: > > Sum > (CP_EX_1,CP_EX_2,CP_EX_3,CP_IN_1,CP_IN_2,CP_IN_3,CP_RE_1,CP_RE_2,CP_RE_3,CP_TR_1,CP_TR_2,CP_TR_3) > > My if statement seems to be the problem.� I thought that I could "or" to > create a set.... > > if (CP_EX_1 | CP_EX_2 | CP_EX_3 | CP_IN_1 | CP_IN_2 | CP_IN_3 | CP_RE_1 | > CP_RE_2 | CP_RE_3 | CP_TR_1 | CP_TR_2 | CP_TR_3) ~= 99 > > > Is there a better way to do this? > > S. Hayes > Empire State College > -- View this message in context: http://spssx-discussion.1045642.n5.nabble.com/Need-help-excluding-a-value-when-computing-a-variable-tp4522009p4522298.html Sent from the SPSSX Discussion mailing list archive at Nabble.com. ===================== 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 ===================== 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 |
Years ago, I wanted pro-rated totals so that there could be an
item or two missing without biasing the sum. That's easy to do : Use the MEAN.n( ) function instead of SUM, and then multiply by the total number of items. Then I noticed that I really preferred to look at the item-average instead of the sum, because it gave me a natural set of anchors -- "4.3 on the scale of 1 to 5" is easier to interpret than "30 on a scale of 7 to 35 with 7 items" or "23 on a scale of 0 to 28." -- Rich Ulrich > Date: Sat, 25 Jun 2011 09:20:29 +0200 > From: [hidden email] > Subject: Re: Need help excluding a value when computing a variable > To: [hidden email] > > There's a set of tutorials on page "3.5 Derived variables (COUNT and COMPUTE)" of my website which covers summing Likert type scales (including reversing codes if necessary) with fully worked examples. > > http://surveyresearch.weebly.com/block-3-analysing-two-variables-and-sometimes-three.html > > You can also check how many items are missing by: > > COUNT x = <varlist> (99). > FREQ x . > > . . where <varlist> can be all 12 in your list or, judging by your varnames, separate sets of 3. > > If your items are coded eg 1 - 5, and you're adding them together to form a scale, it's sometimes advisable to create a zero point by subtracting the number of items summed. > |
Art On 6/25/2011 3:03 PM, Rich Ulrich wrote: ===================== 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
Art Kendall
Social Research Consultants |
Free forum by Nabble | Edit this page |