I am new to SPSS syntax, and I am having trouble using macros in
conjunction with the other features of spss.
My goal is to run a particular macro 500 times. This macro takes 21
arguments. I'm hoping that the first argument can be an index of what
iteration (out of 500) the macro is on. The remaining twenty are a
random sequence of numbers from 1-20. My initial idea was to store
sequences in 20 variables (grouped as 1 vector) of 500 cases each.
Each row represents a set of arguments I would like to use once. (I
am open to transposing, of course, such that each column is one set of
20 arguments, if that would work better. I think I would use DO
REPEAT in that case?) I would then use loop to cycle through the
variables case by case, giving the values of the 20 variables at each
case as arguments. The code looks a bit like this:
vector Vector1 = var001 to var020.
LOOP #J = 1 TO 500.
SplitHalf_IAT_Corr_20Trials #RAND = #J/ t1 = Vector1(1)/t2 = Vector1
(2)/t3 = Vector1(3)/t4 = Vector1(4)/t5 = Vector1(5)/t6 =
Vector1(6)/t7 = Vector1(7)/t8 = Vector1(8)/t9 = Vector1(9)/t10 =
Vector1(10)/t11 = Vector1(11)/
t12 = Vector1(12)/t13 = Vector1(13)/t14 = Vector1(14)/t15 = Vector1
(15)/ t16 = Vector1(16)/
t17 = Vector1(17)/t18 = Vector1(18)/t19 = Vector1(19)/t20 = Vector1
(20).
END LOOP.
I know that the macro (SplitHalf_IAT_Corr) works when I put in the
arguments manually. However, trying to synch it up with loop and
vectors gives me all kinds of problems. First, the macro contains
several instances of the "execute" command, which loop doesn't seem to
like. Second, when I don't use the loop, the macro doesn't seem to
recognize the vector variables.
I don't understand how these commands are supposed to work together!
My task is rather simple; I'm looking for something much like a
traditional "while" command in java or C++.
Any tips or insight would be extremely useful! Many thanks in
advance,
Doc Edge
vector Vector1 = var001 to var020.
begin program.
import spss
i=1
j=2
while i <= 500:
spss.Submit("compute Vector1("+ i +")=Vector1("+ i +")/t"+ j +".")
i=i+1
j=j+1
spss.Submit("exe.")
end program.
I can't tell what you are trying to do, but I've used Vectors
enough to learn some of their oddities. For instance a Vector
is only in existence for "one procedure", and I expect that this
means that it goes away after the first Execute.
If you don't really need the Executes, delete those lines.
Otherwise, figure how to program so that you CAN delete those
lines. Or use another solution.
>
>I don't understand how these commands are supposed to work together!
>My task is rather simple; I'm looking for something much like a
>traditional "while" command in java or C++.
>
>Any tips or insight would be extremely useful! Many thanks in
>advance,
--
Rich Ulrich