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 (October 2001)Back to main SPSSX-L pageJoin or leave SPSSX-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:   Fri, 5 Oct 2001 14:28:16 -0300
Sender:   "SPSSX(r) Discussion" <SPSSX-L@LISTSERV.UGA.EDU>
From:   Hector Maletta <hmaletta@FIBERTEL.COM.AR>
Subject:   Re: Help
Comments:   To: Subhash Lonial <lonial@LOUISVILLE.EDU>
Content-Type:   text/plain; charset=us-ascii

Subhash, you may use the LAG function, as follows:

if (sysmis(var001))var001=0. SORT CASES BY VAR002 (A) VAR001 (D). IF (VAR002=LAG(VAR002))VAR001=LAG(VAR001). EXECUTE.

The first command recodes var001 assigning zero to all balnk cases. The second command sorts the cases in the order you want. First they are ordered by VAR002 in ascending order (from "aaaa" to "zzzz". Then within each VAR002 value they are order by DESCENDING value of VAR001; the order is descending to place zeroes after any numeric value greater than zero, such as the 1 or 13 of your example. The third command copies the previous value of var001 whenever var002 equals the previous value of var002. This is done case by case, so when case #3 is examined, case #2 has already var001=1.

Hope this works fine for you.

Hector Maletta Universidad del Salvador Buenos Aires, Argentina > Subhash Lonial wrote: > > I have spss 10.0 data set , 50 variables and 60,000 observations. Two > variables of interest are var001 (numerical) and var002 (four > character string). > var001 var002 > 1 abcd > . abcd > . abcd > . abcd > 13 azcb > . azcb > . azcb > . . > . . > I need to assign value of 1 to var001 for the next three observations > and a value of 13 to next set of observations till the value of var001 > changes to some other value. var001 can go from 1 to 30 and var002 can > have all combinations. > I tried to use a select if command but it is time consuming. Is there > a way to use macro. I do not know macro. Any suggestion. > Thanks. > Subhash C. Lonial > Professor of Marketing > College of Business & Public Administration > University of Louisville > Louisville, Kentucky 40292 > Tel. 502-852-4852 > Fax. 502-852-7672

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