I understood the question a bit differently that Gene did. If I follow, the

following DO-REPEAT structure will give the desired result:

DO REPEAT

Result = LH_LE_NORM_I1_NULLmean_plusSD MG_LE_NORM_I1_NULLmean_plusSD

RF_LE_NORM_I1_NULLmean_plusSD SOL_LE_NORM_I1_NULLmean_plusSD

TA_LE_NORM_I1_NULLmean_plusSD VL_LE_NORM_I1_NULLmean_plusSD /

M = LH_LE_NORM_I1_avg_norm_I1t_mean_1 MG_LE_NORM_I1_avg_norm_I1t_mean_1

RF_LE_NORM_I1_avg_norm_I1t_mean_1 SOL_LE_NORM_I1_avg_norm_I1t_mean_1

TA_LE_NORM_I1_avg_norm_I1t_mean_1 VL_LE_NORM_I1_avg_norm_I1t_mean_1 /

S = LH_LE_NORM_I1_avg_norm_I1t_sd MG_LE_NORM_I1_avg_norm_I1t_sd

RF_LE_NORM_I1_avg_norm_I1t_sd SOL_LE_NORM_I1_avg_norm_I1t_sd

TA_LE_NORM_I1_avg_norm_I1t_sd VL_LE_NORM_I1_avg_norm_I1t_sd.

COMPUTE Result = M+S.

END REPEAT.

EXECUTE.

But given the length of those variable names, that code is ugly and probably

hard to maintain. Here's a macro that does the same thing:

* Define the macro.

DEFINE !myloop (list = !CMDEND)

!DO !prefix !IN (!list)

!LET !result = !CONCAT(!prefix,"_LE_NORM_I1_NULLmean_plusSD")

!LET !mean = !CONCAT(!prefix,"_LE_NORM_I1_avg_norm_I1t_mean_1")

!LET !sd = !CONCAT(!prefix,"_LE_NORM_I1_avg_norm_I1t_sd")

COMPUTE !result = !mean + !sd.

!DOEND

!ENDDEFINE.

* End of macro definition.

* Now call the macro.

* When you have verified that it works, you might

* wish to remove or comment out the two SET commands.

SET MPRINT ON.

!myloop list = LH MG RF SOL TA VL.

EXECUTE.

SET MPRINT OFF.

When I ran this code, a lot of errors were generated because I had no

dataset with the needed variable names. But I could see that the code

generated the following COMPUTE commands:

COMPUTE LH_LE_NORM_I1_NULLmean_plusSD = LH_LE_NORM_I1_avg_norm_I1t_mean_1 +

LH_LE_NORM_I1_avg_norm_I1t_sd.

COMPUTE MG_LE_NORM_I1_NULLmean_plusSD = MG_LE_NORM_I1_avg_norm_I1t_mean_1 +

MG_LE_NORM_I1_avg_norm_I1t_sd.

COMPUTE RF_LE_NORM_I1_NULLmean_plusSD = RF_LE_NORM_I1_avg_norm_I1t_mean_1 +

RF_LE_NORM_I1_avg_norm_I1t_sd.

COMPUTE SOL_LE_NORM_I1_NULLmean_plusSD = SOL_LE_NORM_I1_avg_norm_I1t_mean_1

+ SOL_LE_NORM_I1_avg_norm_I1t_sd.

COMPUTE TA_LE_NORM_I1_NULLmean_plusSD = TA_LE_NORM_I1_avg_norm_I1t_mean_1 +

TA_LE_NORM_I1_avg_norm_I1t_sd.

COMPUTE VL_LE_NORM_I1_NULLmean_plusSD = VL_LE_NORM_I1_avg_norm_I1t_mean_1 +

VL_LE_NORM_I1_avg_norm_I1t_sd.

I think this is what the OP was looking for. If not, please clarify.

PS- I borrowed a macro that Mario posted in the "Macro for GLM thread

(

http://spssx-discussion.1045642.n5.nabble.com/Macro-for-GLM-td5738269.html)

and tweaked it a bit.

krudolph wrote

> I have several variables that have very similar names that I need to add

> together. I have used For Loops in other programming languages but I

> can't

> figure out how to do it in SPSS.

>

> eg.

>

> COMPUTE LH_LE_NORM_I1_NULLmean_plusSD=LH_LE_NORM_I1_avg_norm_I1t_mean_1 +

> LH_LE_NORM_I1_avg_norm_I1t_sd.

> EXECUTE.

>

> COMPUTE LH_LE_NORM_I1_NULLmean_minusSD=LH_LE_NORM_I1_avg_norm_I1t_mean_1 -

> LH_LE_NORM_I1_avg_norm_I1t_sd.

> EXECUTE.

>

> The variables are all named exactly the same way except the LH at the

> beginning of the variable name changes to MG RF SOL TA and VL

>

> eg.

>

> COMPUTE MG_LE_NORM_I1_NULLmean_plusSD=MG_LE_NORM_I1_avg_norm_I1t_mean_1 +

> MG_LE_NORM_I1_avg_norm_I1t_sd.

> EXECUTE.

>

> COMPUTE MG_LE_NORM_I1_NULLmean_minusSD=MG_LE_NORM_I1_avg_norm_I1t_mean_1 -

> MG_LE_NORM_I1_avg_norm_I1t_sd.

> EXECUTE.

>

> I would like to make a variable that contains a list of the initials and

> then replace the "LH" in the commands with each item in the list.

>

> I hope I've explained this well enough. Any suggestions?

>

> Thank you in advance.

>

>

>

> --

> Sent from:

http://spssx-discussion.1045642.n5.nabble.com/>

> =====================

> 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

-----

--

Bruce Weaver

[hidden email]
http://sites.google.com/a/lakeheadu.ca/bweaver/"When all else fails, RTFM."

NOTE: My Hotmail account is not monitored regularly.

To send me an e-mail, please use the address shown above.

--

Sent from:

http://spssx-discussion.1045642.n5.nabble.com/=====================

To manage your subscription to SPSSX-L, send a message to

[hidden email] (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