LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous messageNext messagePrevious in topicNext in topicPrevious by same authorNext by same authorPrevious page (February 2012)Back to main SPSSX-L pageJoin or leave SPSSX-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Fri, 17 Feb 2012 05:45:46 -0800
Reply-To:     David Marso <david.marso@gmail.com>
Sender:       "SPSSX(r) Discussion" <SPSSX-L@LISTSERV.UGA.EDU>
From:         David Marso <david.marso@gmail.com>
Subject:      Re: New variables as mean of others
In-Reply-To:  <201202162033.q1GIvqIm029637@waikiki.cc.uga.edu>
Content-Type: text/plain; charset=us-ascii

Slightly out of character for me ;-) --- data list free / x1 TO x10. BEGIN DATA 1 2 3 4 5 6 7 8 9 10 2 3 4 5 6 7 8 9 10 11 END DATA.

VARSTOCASES MAKE Xvar FROM ALL/ ID ID. SPLIT FILE BY ID. CREATE AVG3=MA(XVar,3). CASESTOVARS ID=ID .

matti wrote > > I posted something similar but slightly different a couple of weeks ago. > > I have monthly data and I need to create new variables that are the mean > of > trailing three months. For example with data like this > > data list list / start V2011_1 to V2011_12 (13f5.0). > begin data > 1 1 2 3 4 5 6 7 8 9 10 11 12 > 2 1 2 3 4 5 6 7 8 9 10 11 12 > 3 12 11 10 9 8 7 6 5 4 3 2 1 > 4 12 11 10 9 8 7 6 5 4 3 2 1 > end data. > > > I would need to get > Average2011_3 = mean(V2011_1 to V2011_3). > Average2011_4 = mean(V2011_2 to V2011_4). > Average2011_5 = mean(V2011_3 to V2011_5). > > etc. > I need to do this for several years and for several types of variables so > I > think a macro would be helpful. > > I thought know my way around macros with !do commands but they don't work, > I > guess I need loop commands and they are definitely not my strongest side - > any advice is greatly appreciated. > > Matt > > ===================== > To manage your subscription to SPSSX-L, send a message to > LISTSERV@.UGA (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 >

-- View this message in context: http://spssx-discussion.1045642.n5.nabble.com/New-variables-as-mean-of-others-tp5490673p5492538.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