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 2006)Back to main SPSSX-L pageJoin or leave SPSSX-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Thu, 2 Feb 2006 16:50:18 -0500
Reply-To:     Bob Walker <rwwalker-xl@spamarrest.com>
Sender:       "SPSSX(r) Discussion" <SPSSX-L@LISTSERV.UGA.EDU>
From:         Bob Walker <rwwalker-xl@spamarrest.com>
Subject:      Re: help on repeat loop
Comments: cc: Vivek Kurup <vkurup@opinionsearch.com>
In-Reply-To:  <A199185464CED211BC9800805FC7D18F0C3FF7B4@xchng1.net.prv>
Content-type: text/plain; charset=us-ascii

Hi Vivek,

You have an unequal number of elements, so you could either (1) string the sequence out manually, (2) use an index counter (i.e., VECTOR) to write out w1-w4 and y1-y4 to new (repeating) variables, or (3) use a macro to write multiple stand-in variables for each block of four, as in:

DEFINE !VIV (VARS = !CMDEND). DO REPEAT W=1 TO 4 / X=BRAND1 TO BRAND4 !DO !I !IN (!VARS) !CONCAT("/",!I,"=") !DO !J = 1 !TO 4 !CONCAT("VAR_",!I,!J) !DOEND !DOEND !DO !I !IN (!VARS) !CONCAT("/C",!I,"=") !DO !J = 1 !TO 4 !CONCAT("CVAR_",!I,!J) !DOEND !DOEND.

!DO !I !IN (!VARS) IF X=W !CONCAT("C",!I)=!I. !DOEND.

END REPEAT.

!ENDDEFINE. !VIV VARS = A KK.

Note that the last line would contain A B C D E .... KK depending upon how many blocks you have.

Regards,

Bob Walker Surveys & Forecasts, LLC www.surveys-forecasts.com

-----Original Message----- From: SPSSX(r) Discussion [mailto:SPSSX-L@LISTSERV.UGA.EDU] On Behalf Of Vivek Kurup Sent: Thursday, February 02, 2006 11:23 AM To: SPSSX-L@LISTSERV.UGA.EDU Subject: help on repeat loop

Hello All,

This is probably the next level of a previously mentioned problem. I have the following syntax:

DO REPEAT w = 1 to 4 /x= VAR_A1 to VAR_A4 /y= brand1 to brand4 /z= CVAR_A1 to CVAR_A4. do if (x=w). compute z=y. end if. END REPEAT.

This works fine for the above set of VAR_A1 TO VAR_A4. However I have variables till VAR_KK1 to VAR_KK4 (37 sets of 4 in each). Since I do not want to create a counter variable (having values 1 to 37) AND since I do not have much experience with Macros, is there a way to tweak this?

Thanks, Vivek


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