```Date: Thu, 17 Mar 2011 05:05:07 -0700 Reply-To: David Marso Sender: "SPSSX(r) Discussion" From: David Marso Subject: Re: Calculating a mean within a vector In-Reply-To: <1300356548618-3868612.post@n5.nabble.com> Content-Type: text/plain; charset=us-ascii Add an inner loop and manually calculate your means. Vector Gesprekstevredenheid = Gesprekstevredenheid.1 to Gesprekstevredenheid.116 . Vector Meting(5). ***NOT Vector= Meting1 to Meting5 (unless these already exist). LOOP b=1 to 5. + compute Interval_AFG=whatever...... + COMPUTE mysum=0. + compute myN=0. + LOOP c=(Interval_AFG*b)-(Interval_AFG-1) TO Interval_AFG*b. + compute mysum=mysum+Gesprekstevredenheid(c). + compute myN=myN+1. + END LOOP. + COMPUTE meting(b) =mysum/myn. END LOOP. TimBakers wrote: > > Dear all, > > I'm fairly new to spss so please forgive me if i'm over or > undercomplicating this problem.. > > I am trying to calculate 5 means per testsubject in my spss datafile (i > have over 550 subjects). > These means represent time periods from start to finish and my goal is to > do a repeated measure on this data. > It is the case that not all test subjects have recieved the same amount of > scores over the entire period, some have over a 100, while others have > less than 20 for example. > I still want to obtain 5 mean scores per subject, so this means for a > person with a 100 scores i will have to average 20 scores per period, > while a subject with 20 scores only needs 4 scores per period. > > my thought was to create a vector of all the scores (scores 1 to 116 with > 116 being the maximum amount of scores 1 person has obtained. This vector > is called "Gesprekstevredenheid" > > I have also created an interval index which comes down to the total amount > of scores recieved, devided by 5, to indicate how many scores per period > need to be averaged per person. this variable is called Interval_AFG. > > my syntax so far... > > Vector Gesprekstevredenheid = Gesprekstevredenheid.1 to > Gesprekstevredenheid.116 . > Vector Meting = Meting1 to Meting5 . > > loop b = 1 to 5. > compute meting(b) = mean > (Gesprekstevredenheid((Interval_AFG*b)-(Interval_AFG-1)) TO > Gesprekstevredenheid(Interval_AFG*b)) . > end loop . > EXECUTE . > > Meting 1 to 5 are the variables i want to put the averages per period. The > math part seems to work ((Interval_AFG*b)-(Interval_AFG-1)), > (Interval_AFG*b)), but I keep getting error messages about the TO oparator > between the two vectorindexes. I have come to the conclusion that a TO > oparator does not work when working with a vector (because if I use normal > variables instead the code works), but I have totally no clue how to do it > otherwise.. > > If someone has an idea what to typ instead of the TO operator, or an > entirely new way of doing what I am intending to do, you help would be > very very welcome... > > Best regards, Tim > -- View this message in context: http://spssx-discussion.1045642.n5.nabble.com/Calculating-a-mean-within-a-vector-tp3868612p3873788.html Sent from the SPSSX Discussion mailing list archive at Nabble.com. ===================== To manage your subscription to SPSSX-L, send a message to LISTSERV@LISTSERV.UGA.EDU (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 ```

Back to: Top of message | Previous page | Main SPSSX-L page