|
Hello everyone,
I was wondering if you could help me out with this (probably really simple for everyone, besides myself) problem. Suppose I had the following dataset: sex happ1 happ2 happ3 happ4 male 1 1 0 0 male 0 1 1 1 male 0 0 0 1 male 1 1 0 0 male 0 1 0 0 male 1 1 0 0 A subject is given 4 evaluations, with a "1" meaning "happy." What would you suggest the best way to get the average among all "happy" cases? For example, the average frequency here is 45.83% (11 out of 24), but is there a way to get this number in SPSS? I was considering creating a new variable using AGGREGATE and then maybe computing a sum of the aggregates and dividing by the total sample count (or something like that). The only other way I can think of is to do a VARSTOCASES command so that I'll have one variable with everything in it, which I can just FREQ. Any thoughts are appreciated. Thanks! -Lee |
|
Administrator
|
MATRIX.
GET data /FILE * / VARIABLES happ1 TO happ4. COMPUTE avg=MSUM(data)/NROW(data)*NCOL(data). PRINT avg. END MATRIX. Or you could do with AGGREGATE or the VARSTOCASES.
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?" |
|
In reply to this post by CJLee
Lee
It's not clear exactly what you want, or how your variables happ1 to happ4 are coded. It would help if we could see your questionnaire items and the coding scheme. If happ1 to happ4 are only coded 0,1 and you only have 24 cases, I'm not sure that the data will stand much statistical analysis other than simple descriptives. If all you want an average across the four happy items for each case, something like: compute sumhap = sum.4 (happ1 to happ4). compute avhap = sumhap/4. . . or the whole calculation in one line: compute avhap = sum.4 (happ1 to happ4)/4. You can also count the number of happy responses. count numhap = happ1 to happ4 (1). If you want to average across all cases then: desc sumhap avhap numhap. You can get a histogram overlaid with a normal curve (no frequency count) freq avhap /for not/ his nor. If happ1 to happ4 are coded 0,1 and there are no missing data, sumhap and numhap should be the same. Hope this helps. John F Hall (Mr) [Retired academic survey researcher] Email: [hidden email] Website: www.surveyresearch.weebly.com SPSS start page: www.surveyresearch.weebly.com/1-survey-analysis-workshop -----Original Message----- From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of CJLee Sent: 10 November 2015 02:39 To: [hidden email] Subject: Creating variable that is the average of multiple frequencies Hello everyone, I was wondering if you could help me out with this (probably really simple for everyone, besides myself) problem. Suppose I had the following dataset: sex happ1 happ2 happ3 happ4 male 1 1 0 0 male 0 1 1 1 male 0 0 0 1 male 1 1 0 0 male 0 1 0 0 male 1 1 0 0 A subject is given 4 evaluations, with a "1" meaning "happy." What would you suggest the best way to get the average among all "happy" cases? For example, the average frequency here is 45.83% (11 out of 24), but is there a way to get this number in SPSS? I was considering creating a new variable using AGGREGATE and then maybe computing a sum of the aggregates and dividing by the total sample count (or something like that). The only other way I can think of is to do a VARSTOCASES command so that I'll have one variable with everything in it, which I can just FREQ. Any thoughts are appreciated. Thanks! -Lee -- View this message in context: http://spssx-discussion.1045642.n5.nabble.com/Creating-variable-that-is-the- average-of-multiple-frequencies-tp5730922.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 |
|
Administrator
|
In reply to this post by David Marso
Nice method, David. But you need to enclose NROW(data)*NCOL(data) in parentheses on that COMPUTE line.
COMPUTE avg=MSUM(data) / ( NROW(data)*NCOL(data) ). Results: Without parentheses: 7.333333333 With parentheses: .4583333333 Multiply by 100 if you need to display as a percentage rather than a proportion.
--
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 CJLee
I used v1 to v4 rather than "happ." Anyway, try this:
COUNT count1=v1 v2 v3 v4(1). COUNT countany=v1 v2 v3 v4(0 thru 1). DATASET DECLARE sums. AGGREGATE /OUTFILE='sums' /BREAK= /count1_sum=SUM(count1) /countany_sum=SUM(countany). DATASET ACTIVATE sums. COMPUTE ratio=count1_sum/countany_sum. EXECUTE. Tony Babinec [hidden email] ===================== 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 Bruce Weaver
Good catch my friend!
--
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?" |
| Free forum by Nabble | Edit this page |
