--------------------------------------------------------------------- The following series of newsgroups includes a nice example of how to take advantage of the fact that scratch variables in SPSS retain their value from case to case. --------------------------------------------------------------------- From: "adrian" Newsgroups: comp.soft-sys.stat.spss Subject: Using variables across multiple .sav files Date: Sat, 2 Oct 2004 12:08:14 -0700 Hi, I have the following problem: Name Income ------------------------------- Peter $1400 John $1200 Mary $1500 . . Jane $2400 I need to have a third column known as PerMax where PerMax = (Income / Maximum Income) * 100%. Hence, I use the aggregate procedure to output the aggregate variable, maxIncome in a separate file. May I know how to I retrieve that aggregate variable, maxIncome in the separate file so that I can derive the third column in my syntax file ? Thanks. Regards, Adrian --------------------------------------------------------------------- From: Michael Lacy Subject: Re: Using variables across multiple .sav files Newsgroups: comp.soft-sys.stat.spss Date: 2 Oct 2004 10:24:45 -0700 You can "retrieve" that maximum variable from the aggregate file by using MATCH FILES. However, there's another way to do this that I might suggest: sort cases income (d) . if ($casenum eq 1) #max = income . compute permax = #max . exe . -- =-=-=-=-=-=-=-=-=-==-=-=-= Mike Lacy, Ft Collins CO 80523 Clean out the 'junk' to email me. --------------------------------------------------------------------- From: Bruce Weaver Newsgroups: comp.soft-sys.stat.spss Subject: Re: Using variables across multiple .sav files Date: Mon, 04 Oct 2004 07:15:02 -0400 Michael.Lacy.junk@colostate.edu wrote: > You can "retrieve" that maximum variable from the aggregate file > by using MATCH FILES. However, there's another way to do this > that I might suggest: > > sort cases income (d) . > if ($casenum eq 1) #max = income . > compute permax = #max . > exe . And this works because scratch variables (i.e., variables that start with #) retain their value from one case to the next. Thanks for the reminder, Mike--that's a useful trick. I think the OP wanted the following though, as the final compute statement: compute permax = income/#max*100 . Cheers, Bruce -- Bruce Weaver bweaver@lakeheadu.ca www.angelfire.com/wv/bwhomedir ---------------------------------------------------------------------