Somebody who knows much about macros???

classic Classic list List threaded Threaded
11 messages Options
Reply | Threaded
Open this post in threaded view
|

Somebody who knows much about macros???

maartjegoorden
Hello! I am pretty new at spss macro's, but I think I need one.

I have 400 variables, I want to do this loop 400 times.  My variables are ordered consecutively. Who can help me ? So first I want to do this loop for variables 1 to 4, than for variables 5 to 8, than for variables 8 to 12 and so on.

vector TEQ5DBv=T0EQ5DNL to T4EQ5DNL.
loop #index = 1 to 4.
+ IF( MISSING(TEQ5DBv(#index+1))) TEQ5DBv(#index+1) = TEQ5DBv(#index) .
end loop .
EXECUTE .

Thank you very much!

Greetings maartje
Reply | Threaded
Open this post in threaded view
|

Re: Somebody who knows much about macros???

Albert-Jan Roskam
Hello,

The Python code below sends the Spss code below to the Spss processor. You only need to run the BEGIN/END PROGRAM block. Is this what you mean? I was not sure about your variable names. Python does the same as macro code, but is easier and much more versatile.

BEGIN PROGRAM.
import os
import spss
sep = os.linesep
cmds = ""
for n in range(0, 400):
    if n > 0 and n % 5 != 0:
        cmd = "IF( MISSING(T%dEQ5DNL) ) T%dEQ5DNL = T%dEQ5DNL.%s" % (n, n, n-1, sep)
    else:
        cmd = "*" + 50 * "-" + ".%s* New block (%d-%d).%s" % (sep, n, n+4, sep) + "*" + 50 * "-" + ".%s" % sep
    cmds += cmd
spss.Submit(cmds)
END PROGRAM.

*--------------------------------------------------.

* New block (0-4).

*--------------------------------------------------.

IF( MISSING(T1EQ5DNL) ) T1EQ5DNL = T0EQ5DNL.

IF( MISSING(T2EQ5DNL) ) T2EQ5DNL = T1EQ5DNL.

IF( MISSING(T3EQ5DNL) ) T3EQ5DNL = T2EQ5DNL.

IF( MISSING(T4EQ5DNL) ) T4EQ5DNL = T3EQ5DNL.

*--------------------------------------------------.

* New block (5-9).

*--------------------------------------------------.

IF( MISSING(T6EQ5DNL) ) T6EQ5DNL = T5EQ5DNL.

IF( MISSING(T7EQ5DNL) ) T7EQ5DNL = T6EQ5DNL.

IF( MISSING(T8EQ5DNL) ) T8EQ5DNL = T7EQ5DNL.

IF( MISSING(T9EQ5DNL) ) T9EQ5DNL = T8EQ5DNL.

*--------------------------------------------------.

* New block (10-14).

*--------------------------------------------------.

IF( MISSING(T11EQ5DNL) ) T11EQ5DNL = T10EQ5DNL.

IF( MISSING(T12EQ5DNL) ) T12EQ5DNL = T11EQ5DNL.

IF( MISSING(T13EQ5DNL) ) T13EQ5DNL = T12EQ5DNL.

IF( MISSING(T14EQ5DNL) ) T14EQ5DNL = T13EQ5DNL.

*--------------------------------------------------.

* New block (15-19).

*--------------------------------------------------.

IF( MISSING(T16EQ5DNL) ) T16EQ5DNL = T15EQ5DNL.

IF( MISSING(T17EQ5DNL) ) T17EQ5DNL = T16EQ5DNL.

IF( MISSING(T18EQ5DNL) ) T18EQ5DNL = T17EQ5DNL.

IF( MISSING(T19EQ5DNL) ) T19EQ5DNL = T18EQ5DNL.

*--------------------------------------------------.

* New block (20-24).

*--------------------------------------------------.

IF( MISSING(T21EQ5DNL) ) T21EQ5DNL = T20EQ5DNL.

IF( MISSING(T22EQ5DNL) ) T22EQ5DNL = T21EQ5DNL.

IF( MISSING(T23EQ5DNL) ) T23EQ5DNL = T22EQ5DNL.

IF( MISSING(T24EQ5DNL) ) T24EQ5DNL = T23EQ5DNL.

*--------------------------------------------------.

* New block (25-29).

*--------------------------------------------------.

IF( MISSING(T26EQ5DNL) ) T26EQ5DNL = T25EQ5DNL.

IF( MISSING(T27EQ5DNL) ) T27EQ5DNL = T26EQ5DNL.

IF( MISSING(T28EQ5DNL) ) T28EQ5DNL = T27EQ5DNL.

IF( MISSING(T29EQ5DNL) ) T29EQ5DNL = T28EQ5DNL.

*--------------------------------------------------.

* New block (30-34).

*--------------------------------------------------.

IF( MISSING(T31EQ5DNL) ) T31EQ5DNL = T30EQ5DNL.

IF( MISSING(T32EQ5DNL) ) T32EQ5DNL = T31EQ5DNL.

IF( MISSING(T33EQ5DNL) ) T33EQ5DNL = T32EQ5DNL.

IF( MISSING(T34EQ5DNL) ) T34EQ5DNL = T33EQ5DNL.

*--------------------------------------------------.

* New block (35-39).

*--------------------------------------------------.

IF( MISSING(T36EQ5DNL) ) T36EQ5DNL = T35EQ5DNL.

IF( MISSING(T37EQ5DNL) ) T37EQ5DNL = T36EQ5DNL.

IF( MISSING(T38EQ5DNL) ) T38EQ5DNL = T37EQ5DNL.

IF( MISSING(T39EQ5DNL) ) T39EQ5DNL = T38EQ5DNL.

*--------------------------------------------------.

* New block (40-44).

*--------------------------------------------------.

IF( MISSING(T41EQ5DNL) ) T41EQ5DNL = T40EQ5DNL.

IF( MISSING(T42EQ5DNL) ) T42EQ5DNL = T41EQ5DNL.

IF( MISSING(T43EQ5DNL) ) T43EQ5DNL = T42EQ5DNL.

IF( MISSING(T44EQ5DNL) ) T44EQ5DNL = T43EQ5DNL.

*--------------------------------------------------.

* New block (45-49).

*--------------------------------------------------.

IF( MISSING(T46EQ5DNL) ) T46EQ5DNL = T45EQ5DNL.

IF( MISSING(T47EQ5DNL) ) T47EQ5DNL = T46EQ5DNL.

IF( MISSING(T48EQ5DNL) ) T48EQ5DNL = T47EQ5DNL.

IF( MISSING(T49EQ5DNL) ) T49EQ5DNL = T48EQ5DNL.

*--------------------------------------------------.

* New block (50-54).

*--------------------------------------------------.

IF( MISSING(T51EQ5DNL) ) T51EQ5DNL = T50EQ5DNL.

IF( MISSING(T52EQ5DNL) ) T52EQ5DNL = T51EQ5DNL.

IF( MISSING(T53EQ5DNL) ) T53EQ5DNL = T52EQ5DNL.

IF( MISSING(T54EQ5DNL) ) T54EQ5DNL = T53EQ5DNL.

*--------------------------------------------------.

* New block (55-59).

*--------------------------------------------------.

IF( MISSING(T56EQ5DNL) ) T56EQ5DNL = T55EQ5DNL.

IF( MISSING(T57EQ5DNL) ) T57EQ5DNL = T56EQ5DNL.

IF( MISSING(T58EQ5DNL) ) T58EQ5DNL = T57EQ5DNL.

IF( MISSING(T59EQ5DNL) ) T59EQ5DNL = T58EQ5DNL.

*--------------------------------------------------.

* New block (60-64).

*--------------------------------------------------.

IF( MISSING(T61EQ5DNL) ) T61EQ5DNL = T60EQ5DNL.

IF( MISSING(T62EQ5DNL) ) T62EQ5DNL = T61EQ5DNL.

IF( MISSING(T63EQ5DNL) ) T63EQ5DNL = T62EQ5DNL.

IF( MISSING(T64EQ5DNL) ) T64EQ5DNL = T63EQ5DNL.

*--------------------------------------------------.

* New block (65-69).

*--------------------------------------------------.

IF( MISSING(T66EQ5DNL) ) T66EQ5DNL = T65EQ5DNL.

IF( MISSING(T67EQ5DNL) ) T67EQ5DNL = T66EQ5DNL.

IF( MISSING(T68EQ5DNL) ) T68EQ5DNL = T67EQ5DNL.

IF( MISSING(T69EQ5DNL) ) T69EQ5DNL = T68EQ5DNL.

*--------------------------------------------------.

* New block (70-74).

*--------------------------------------------------.

IF( MISSING(T71EQ5DNL) ) T71EQ5DNL = T70EQ5DNL.

IF( MISSING(T72EQ5DNL) ) T72EQ5DNL = T71EQ5DNL.

IF( MISSING(T73EQ5DNL) ) T73EQ5DNL = T72EQ5DNL.

IF( MISSING(T74EQ5DNL) ) T74EQ5DNL = T73EQ5DNL.

*--------------------------------------------------.

* New block (75-79).

*--------------------------------------------------.

IF( MISSING(T76EQ5DNL) ) T76EQ5DNL = T75EQ5DNL.

IF( MISSING(T77EQ5DNL) ) T77EQ5DNL = T76EQ5DNL.

IF( MISSING(T78EQ5DNL) ) T78EQ5DNL = T77EQ5DNL.

IF( MISSING(T79EQ5DNL) ) T79EQ5DNL = T78EQ5DNL.

*--------------------------------------------------.

* New block (80-84).

*--------------------------------------------------.

IF( MISSING(T81EQ5DNL) ) T81EQ5DNL = T80EQ5DNL.

IF( MISSING(T82EQ5DNL) ) T82EQ5DNL = T81EQ5DNL.

IF( MISSING(T83EQ5DNL) ) T83EQ5DNL = T82EQ5DNL.

IF( MISSING(T84EQ5DNL) ) T84EQ5DNL = T83EQ5DNL.

*--------------------------------------------------.

* New block (85-89).

*--------------------------------------------------.

IF( MISSING(T86EQ5DNL) ) T86EQ5DNL = T85EQ5DNL.

IF( MISSING(T87EQ5DNL) ) T87EQ5DNL = T86EQ5DNL.

IF( MISSING(T88EQ5DNL) ) T88EQ5DNL = T87EQ5DNL.

IF( MISSING(T89EQ5DNL) ) T89EQ5DNL = T88EQ5DNL.

*--------------------------------------------------.

* New block (90-94).

*--------------------------------------------------.

IF( MISSING(T91EQ5DNL) ) T91EQ5DNL = T90EQ5DNL.

IF( MISSING(T92EQ5DNL) ) T92EQ5DNL = T91EQ5DNL.

IF( MISSING(T93EQ5DNL) ) T93EQ5DNL = T92EQ5DNL.

IF( MISSING(T94EQ5DNL) ) T94EQ5DNL = T93EQ5DNL.

*--------------------------------------------------.

* New block (95-99).

*--------------------------------------------------.

IF( MISSING(T96EQ5DNL) ) T96EQ5DNL = T95EQ5DNL.

IF( MISSING(T97EQ5DNL) ) T97EQ5DNL = T96EQ5DNL.

IF( MISSING(T98EQ5DNL) ) T98EQ5DNL = T97EQ5DNL.

IF( MISSING(T99EQ5DNL) ) T99EQ5DNL = T98EQ5DNL.

*--------------------------------------------------.

* New block (100-104).

*--------------------------------------------------.

IF( MISSING(T101EQ5DNL) ) T101EQ5DNL = T100EQ5DNL.

IF( MISSING(T102EQ5DNL) ) T102EQ5DNL = T101EQ5DNL.

IF( MISSING(T103EQ5DNL) ) T103EQ5DNL = T102EQ5DNL.

IF( MISSING(T104EQ5DNL) ) T104EQ5DNL = T103EQ5DNL.

*--------------------------------------------------.

* New block (105-109).

*--------------------------------------------------.

IF( MISSING(T106EQ5DNL) ) T106EQ5DNL = T105EQ5DNL.

IF( MISSING(T107EQ5DNL) ) T107EQ5DNL = T106EQ5DNL.

IF( MISSING(T108EQ5DNL) ) T108EQ5DNL = T107EQ5DNL.

IF( MISSING(T109EQ5DNL) ) T109EQ5DNL = T108EQ5DNL.

*--------------------------------------------------.

* New block (110-114).

*--------------------------------------------------.

IF( MISSING(T111EQ5DNL) ) T111EQ5DNL = T110EQ5DNL.

IF( MISSING(T112EQ5DNL) ) T112EQ5DNL = T111EQ5DNL.

IF( MISSING(T113EQ5DNL) ) T113EQ5DNL = T112EQ5DNL.

IF( MISSING(T114EQ5DNL) ) T114EQ5DNL = T113EQ5DNL.

*--------------------------------------------------.

* New block (115-119).

*--------------------------------------------------.

IF( MISSING(T116EQ5DNL) ) T116EQ5DNL = T115EQ5DNL.

IF( MISSING(T117EQ5DNL) ) T117EQ5DNL = T116EQ5DNL.

IF( MISSING(T118EQ5DNL) ) T118EQ5DNL = T117EQ5DNL.

IF( MISSING(T119EQ5DNL) ) T119EQ5DNL = T118EQ5DNL.

*--------------------------------------------------.

* New block (120-124).

*--------------------------------------------------.

IF( MISSING(T121EQ5DNL) ) T121EQ5DNL = T120EQ5DNL.

IF( MISSING(T122EQ5DNL) ) T122EQ5DNL = T121EQ5DNL.

IF( MISSING(T123EQ5DNL) ) T123EQ5DNL = T122EQ5DNL.

IF( MISSING(T124EQ5DNL) ) T124EQ5DNL = T123EQ5DNL.

*--------------------------------------------------.

* New block (125-129).

*--------------------------------------------------.

IF( MISSING(T126EQ5DNL) ) T126EQ5DNL = T125EQ5DNL.

IF( MISSING(T127EQ5DNL) ) T127EQ5DNL = T126EQ5DNL.

IF( MISSING(T128EQ5DNL) ) T128EQ5DNL = T127EQ5DNL.

IF( MISSING(T129EQ5DNL) ) T129EQ5DNL = T128EQ5DNL.

*--------------------------------------------------.

* New block (130-134).

*--------------------------------------------------.

IF( MISSING(T131EQ5DNL) ) T131EQ5DNL = T130EQ5DNL.

IF( MISSING(T132EQ5DNL) ) T132EQ5DNL = T131EQ5DNL.

IF( MISSING(T133EQ5DNL) ) T133EQ5DNL = T132EQ5DNL.

IF( MISSING(T134EQ5DNL) ) T134EQ5DNL = T133EQ5DNL.

*--------------------------------------------------.

* New block (135-139).

*--------------------------------------------------.

IF( MISSING(T136EQ5DNL) ) T136EQ5DNL = T135EQ5DNL.

IF( MISSING(T137EQ5DNL) ) T137EQ5DNL = T136EQ5DNL.

IF( MISSING(T138EQ5DNL) ) T138EQ5DNL = T137EQ5DNL.

IF( MISSING(T139EQ5DNL) ) T139EQ5DNL = T138EQ5DNL.

*--------------------------------------------------.

* New block (140-144).

*--------------------------------------------------.

IF( MISSING(T141EQ5DNL) ) T141EQ5DNL = T140EQ5DNL.

IF( MISSING(T142EQ5DNL) ) T142EQ5DNL = T141EQ5DNL.

IF( MISSING(T143EQ5DNL) ) T143EQ5DNL = T142EQ5DNL.

IF( MISSING(T144EQ5DNL) ) T144EQ5DNL = T143EQ5DNL.

*--------------------------------------------------.

* New block (145-149).

*--------------------------------------------------.

IF( MISSING(T146EQ5DNL) ) T146EQ5DNL = T145EQ5DNL.

IF( MISSING(T147EQ5DNL) ) T147EQ5DNL = T146EQ5DNL.

IF( MISSING(T148EQ5DNL) ) T148EQ5DNL = T147EQ5DNL.

IF( MISSING(T149EQ5DNL) ) T149EQ5DNL = T148EQ5DNL.

*--------------------------------------------------.

* New block (150-154).

*--------------------------------------------------.

IF( MISSING(T151EQ5DNL) ) T151EQ5DNL = T150EQ5DNL.

IF( MISSING(T152EQ5DNL) ) T152EQ5DNL = T151EQ5DNL.

IF( MISSING(T153EQ5DNL) ) T153EQ5DNL = T152EQ5DNL.

IF( MISSING(T154EQ5DNL) ) T154EQ5DNL = T153EQ5DNL.

*--------------------------------------------------.

* New block (155-159).

*--------------------------------------------------.

IF( MISSING(T156EQ5DNL) ) T156EQ5DNL = T155EQ5DNL.

IF( MISSING(T157EQ5DNL) ) T157EQ5DNL = T156EQ5DNL.

IF( MISSING(T158EQ5DNL) ) T158EQ5DNL = T157EQ5DNL.

IF( MISSING(T159EQ5DNL) ) T159EQ5DNL = T158EQ5DNL.

*--------------------------------------------------.

* New block (160-164).

*--------------------------------------------------.

IF( MISSING(T161EQ5DNL) ) T161EQ5DNL = T160EQ5DNL.

IF( MISSING(T162EQ5DNL) ) T162EQ5DNL = T161EQ5DNL.

IF( MISSING(T163EQ5DNL) ) T163EQ5DNL = T162EQ5DNL.

IF( MISSING(T164EQ5DNL) ) T164EQ5DNL = T163EQ5DNL.

*--------------------------------------------------.

* New block (165-169).

*--------------------------------------------------.

IF( MISSING(T166EQ5DNL) ) T166EQ5DNL = T165EQ5DNL.

IF( MISSING(T167EQ5DNL) ) T167EQ5DNL = T166EQ5DNL.

IF( MISSING(T168EQ5DNL) ) T168EQ5DNL = T167EQ5DNL.

IF( MISSING(T169EQ5DNL) ) T169EQ5DNL = T168EQ5DNL.

*--------------------------------------------------.

* New block (170-174).

*--------------------------------------------------.

IF( MISSING(T171EQ5DNL) ) T171EQ5DNL = T170EQ5DNL.

IF( MISSING(T172EQ5DNL) ) T172EQ5DNL = T171EQ5DNL.

IF( MISSING(T173EQ5DNL) ) T173EQ5DNL = T172EQ5DNL.

IF( MISSING(T174EQ5DNL) ) T174EQ5DNL = T173EQ5DNL.

*--------------------------------------------------.

* New block (175-179).

*--------------------------------------------------.

IF( MISSING(T176EQ5DNL) ) T176EQ5DNL = T175EQ5DNL.

IF( MISSING(T177EQ5DNL) ) T177EQ5DNL = T176EQ5DNL.

IF( MISSING(T178EQ5DNL) ) T178EQ5DNL = T177EQ5DNL.

IF( MISSING(T179EQ5DNL) ) T179EQ5DNL = T178EQ5DNL.

*--------------------------------------------------.

* New block (180-184).

*--------------------------------------------------.

IF( MISSING(T181EQ5DNL) ) T181EQ5DNL = T180EQ5DNL.

IF( MISSING(T182EQ5DNL) ) T182EQ5DNL = T181EQ5DNL.

IF( MISSING(T183EQ5DNL) ) T183EQ5DNL = T182EQ5DNL.

IF( MISSING(T184EQ5DNL) ) T184EQ5DNL = T183EQ5DNL.

*--------------------------------------------------.

* New block (185-189).

*--------------------------------------------------.

IF( MISSING(T186EQ5DNL) ) T186EQ5DNL = T185EQ5DNL.

IF( MISSING(T187EQ5DNL) ) T187EQ5DNL = T186EQ5DNL.

IF( MISSING(T188EQ5DNL) ) T188EQ5DNL = T187EQ5DNL.

IF( MISSING(T189EQ5DNL) ) T189EQ5DNL = T188EQ5DNL.

*--------------------------------------------------.

* New block (190-194).

*--------------------------------------------------.

IF( MISSING(T191EQ5DNL) ) T191EQ5DNL = T190EQ5DNL.

IF( MISSING(T192EQ5DNL) ) T192EQ5DNL = T191EQ5DNL.

IF( MISSING(T193EQ5DNL) ) T193EQ5DNL = T192EQ5DNL.

IF( MISSING(T194EQ5DNL) ) T194EQ5DNL = T193EQ5DNL.

*--------------------------------------------------.

* New block (195-199).

*--------------------------------------------------.

IF( MISSING(T196EQ5DNL) ) T196EQ5DNL = T195EQ5DNL.

IF( MISSING(T197EQ5DNL) ) T197EQ5DNL = T196EQ5DNL.

IF( MISSING(T198EQ5DNL) ) T198EQ5DNL = T197EQ5DNL.

IF( MISSING(T199EQ5DNL) ) T199EQ5DNL = T198EQ5DNL.

*--------------------------------------------------.

* New block (200-204).

*--------------------------------------------------.

IF( MISSING(T201EQ5DNL) ) T201EQ5DNL = T200EQ5DNL.

IF( MISSING(T202EQ5DNL) ) T202EQ5DNL = T201EQ5DNL.

IF( MISSING(T203EQ5DNL) ) T203EQ5DNL = T202EQ5DNL.

IF( MISSING(T204EQ5DNL) ) T204EQ5DNL = T203EQ5DNL.

*--------------------------------------------------.

* New block (205-209).

*--------------------------------------------------.

IF( MISSING(T206EQ5DNL) ) T206EQ5DNL = T205EQ5DNL.

IF( MISSING(T207EQ5DNL) ) T207EQ5DNL = T206EQ5DNL.

IF( MISSING(T208EQ5DNL) ) T208EQ5DNL = T207EQ5DNL.

IF( MISSING(T209EQ5DNL) ) T209EQ5DNL = T208EQ5DNL.

*--------------------------------------------------.

* New block (210-214).

*--------------------------------------------------.

IF( MISSING(T211EQ5DNL) ) T211EQ5DNL = T210EQ5DNL.

IF( MISSING(T212EQ5DNL) ) T212EQ5DNL = T211EQ5DNL.

IF( MISSING(T213EQ5DNL) ) T213EQ5DNL = T212EQ5DNL.

IF( MISSING(T214EQ5DNL) ) T214EQ5DNL = T213EQ5DNL.

*--------------------------------------------------.

* New block (215-219).

*--------------------------------------------------.

IF( MISSING(T216EQ5DNL) ) T216EQ5DNL = T215EQ5DNL.

IF( MISSING(T217EQ5DNL) ) T217EQ5DNL = T216EQ5DNL.

IF( MISSING(T218EQ5DNL) ) T218EQ5DNL = T217EQ5DNL.

IF( MISSING(T219EQ5DNL) ) T219EQ5DNL = T218EQ5DNL.

*--------------------------------------------------.

* New block (220-224).

*--------------------------------------------------.

IF( MISSING(T221EQ5DNL) ) T221EQ5DNL = T220EQ5DNL.

IF( MISSING(T222EQ5DNL) ) T222EQ5DNL = T221EQ5DNL.

IF( MISSING(T223EQ5DNL) ) T223EQ5DNL = T222EQ5DNL.

IF( MISSING(T224EQ5DNL) ) T224EQ5DNL = T223EQ5DNL.

*--------------------------------------------------.

* New block (225-229).

*--------------------------------------------------.

IF( MISSING(T226EQ5DNL) ) T226EQ5DNL = T225EQ5DNL.

IF( MISSING(T227EQ5DNL) ) T227EQ5DNL = T226EQ5DNL.

IF( MISSING(T228EQ5DNL) ) T228EQ5DNL = T227EQ5DNL.

IF( MISSING(T229EQ5DNL) ) T229EQ5DNL = T228EQ5DNL.

*--------------------------------------------------.

* New block (230-234).

*--------------------------------------------------.

IF( MISSING(T231EQ5DNL) ) T231EQ5DNL = T230EQ5DNL.

IF( MISSING(T232EQ5DNL) ) T232EQ5DNL = T231EQ5DNL.

IF( MISSING(T233EQ5DNL) ) T233EQ5DNL = T232EQ5DNL.

IF( MISSING(T234EQ5DNL) ) T234EQ5DNL = T233EQ5DNL.

*--------------------------------------------------.

* New block (235-239).

*--------------------------------------------------.

IF( MISSING(T236EQ5DNL) ) T236EQ5DNL = T235EQ5DNL.

IF( MISSING(T237EQ5DNL) ) T237EQ5DNL = T236EQ5DNL.

IF( MISSING(T238EQ5DNL) ) T238EQ5DNL = T237EQ5DNL.

IF( MISSING(T239EQ5DNL) ) T239EQ5DNL = T238EQ5DNL.

*--------------------------------------------------.

* New block (240-244).

*--------------------------------------------------.

IF( MISSING(T241EQ5DNL) ) T241EQ5DNL = T240EQ5DNL.

IF( MISSING(T242EQ5DNL) ) T242EQ5DNL = T241EQ5DNL.

IF( MISSING(T243EQ5DNL) ) T243EQ5DNL = T242EQ5DNL.

IF( MISSING(T244EQ5DNL) ) T244EQ5DNL = T243EQ5DNL.

*--------------------------------------------------.

* New block (245-249).

*--------------------------------------------------.

IF( MISSING(T246EQ5DNL) ) T246EQ5DNL = T245EQ5DNL.

IF( MISSING(T247EQ5DNL) ) T247EQ5DNL = T246EQ5DNL.

IF( MISSING(T248EQ5DNL) ) T248EQ5DNL = T247EQ5DNL.

IF( MISSING(T249EQ5DNL) ) T249EQ5DNL = T248EQ5DNL.

*--------------------------------------------------.

* New block (250-254).

*--------------------------------------------------.

IF( MISSING(T251EQ5DNL) ) T251EQ5DNL = T250EQ5DNL.

IF( MISSING(T252EQ5DNL) ) T252EQ5DNL = T251EQ5DNL.

IF( MISSING(T253EQ5DNL) ) T253EQ5DNL = T252EQ5DNL.

IF( MISSING(T254EQ5DNL) ) T254EQ5DNL = T253EQ5DNL.

*--------------------------------------------------.

* New block (255-259).

*--------------------------------------------------.

IF( MISSING(T256EQ5DNL) ) T256EQ5DNL = T255EQ5DNL.

IF( MISSING(T257EQ5DNL) ) T257EQ5DNL = T256EQ5DNL.

IF( MISSING(T258EQ5DNL) ) T258EQ5DNL = T257EQ5DNL.

IF( MISSING(T259EQ5DNL) ) T259EQ5DNL = T258EQ5DNL.

*--------------------------------------------------.

* New block (260-264).

*--------------------------------------------------.

IF( MISSING(T261EQ5DNL) ) T261EQ5DNL = T260EQ5DNL.

IF( MISSING(T262EQ5DNL) ) T262EQ5DNL = T261EQ5DNL.

IF( MISSING(T263EQ5DNL) ) T263EQ5DNL = T262EQ5DNL.

IF( MISSING(T264EQ5DNL) ) T264EQ5DNL = T263EQ5DNL.

*--------------------------------------------------.

* New block (265-269).

*--------------------------------------------------.

IF( MISSING(T266EQ5DNL) ) T266EQ5DNL = T265EQ5DNL.

IF( MISSING(T267EQ5DNL) ) T267EQ5DNL = T266EQ5DNL.

IF( MISSING(T268EQ5DNL) ) T268EQ5DNL = T267EQ5DNL.

IF( MISSING(T269EQ5DNL) ) T269EQ5DNL = T268EQ5DNL.

*--------------------------------------------------.

* New block (270-274).

*--------------------------------------------------.

IF( MISSING(T271EQ5DNL) ) T271EQ5DNL = T270EQ5DNL.

IF( MISSING(T272EQ5DNL) ) T272EQ5DNL = T271EQ5DNL.

IF( MISSING(T273EQ5DNL) ) T273EQ5DNL = T272EQ5DNL.

IF( MISSING(T274EQ5DNL) ) T274EQ5DNL = T273EQ5DNL.

*--------------------------------------------------.

* New block (275-279).

*--------------------------------------------------.

IF( MISSING(T276EQ5DNL) ) T276EQ5DNL = T275EQ5DNL.

IF( MISSING(T277EQ5DNL) ) T277EQ5DNL = T276EQ5DNL.

IF( MISSING(T278EQ5DNL) ) T278EQ5DNL = T277EQ5DNL.

IF( MISSING(T279EQ5DNL) ) T279EQ5DNL = T278EQ5DNL.

*--------------------------------------------------.

* New block (280-284).

*--------------------------------------------------.

IF( MISSING(T281EQ5DNL) ) T281EQ5DNL = T280EQ5DNL.

IF( MISSING(T282EQ5DNL) ) T282EQ5DNL = T281EQ5DNL.

IF( MISSING(T283EQ5DNL) ) T283EQ5DNL = T282EQ5DNL.

IF( MISSING(T284EQ5DNL) ) T284EQ5DNL = T283EQ5DNL.

*--------------------------------------------------.

* New block (285-289).

*--------------------------------------------------.

IF( MISSING(T286EQ5DNL) ) T286EQ5DNL = T285EQ5DNL.

IF( MISSING(T287EQ5DNL) ) T287EQ5DNL = T286EQ5DNL.

IF( MISSING(T288EQ5DNL) ) T288EQ5DNL = T287EQ5DNL.

IF( MISSING(T289EQ5DNL) ) T289EQ5DNL = T288EQ5DNL.

*--------------------------------------------------.

* New block (290-294).

*--------------------------------------------------.

IF( MISSING(T291EQ5DNL) ) T291EQ5DNL = T290EQ5DNL.

IF( MISSING(T292EQ5DNL) ) T292EQ5DNL = T291EQ5DNL.

IF( MISSING(T293EQ5DNL) ) T293EQ5DNL = T292EQ5DNL.

IF( MISSING(T294EQ5DNL) ) T294EQ5DNL = T293EQ5DNL.

*--------------------------------------------------.

* New block (295-299).

*--------------------------------------------------.

IF( MISSING(T296EQ5DNL) ) T296EQ5DNL = T295EQ5DNL.

IF( MISSING(T297EQ5DNL) ) T297EQ5DNL = T296EQ5DNL.

IF( MISSING(T298EQ5DNL) ) T298EQ5DNL = T297EQ5DNL.

IF( MISSING(T299EQ5DNL) ) T299EQ5DNL = T298EQ5DNL.

*--------------------------------------------------.

* New block (300-304).

*--------------------------------------------------.

IF( MISSING(T301EQ5DNL) ) T301EQ5DNL = T300EQ5DNL.

IF( MISSING(T302EQ5DNL) ) T302EQ5DNL = T301EQ5DNL.

IF( MISSING(T303EQ5DNL) ) T303EQ5DNL = T302EQ5DNL.

IF( MISSING(T304EQ5DNL) ) T304EQ5DNL = T303EQ5DNL.

*--------------------------------------------------.

* New block (305-309).

*--------------------------------------------------.

IF( MISSING(T306EQ5DNL) ) T306EQ5DNL = T305EQ5DNL.

IF( MISSING(T307EQ5DNL) ) T307EQ5DNL = T306EQ5DNL.

IF( MISSING(T308EQ5DNL) ) T308EQ5DNL = T307EQ5DNL.

IF( MISSING(T309EQ5DNL) ) T309EQ5DNL = T308EQ5DNL.

*--------------------------------------------------.

* New block (310-314).

*--------------------------------------------------.

IF( MISSING(T311EQ5DNL) ) T311EQ5DNL = T310EQ5DNL.

IF( MISSING(T312EQ5DNL) ) T312EQ5DNL = T311EQ5DNL.

IF( MISSING(T313EQ5DNL) ) T313EQ5DNL = T312EQ5DNL.

IF( MISSING(T314EQ5DNL) ) T314EQ5DNL = T313EQ5DNL.

*--------------------------------------------------.

* New block (315-319).

*--------------------------------------------------.

IF( MISSING(T316EQ5DNL) ) T316EQ5DNL = T315EQ5DNL.

IF( MISSING(T317EQ5DNL) ) T317EQ5DNL = T316EQ5DNL.

IF( MISSING(T318EQ5DNL) ) T318EQ5DNL = T317EQ5DNL.

IF( MISSING(T319EQ5DNL) ) T319EQ5DNL = T318EQ5DNL.

*--------------------------------------------------.

* New block (320-324).

*--------------------------------------------------.

IF( MISSING(T321EQ5DNL) ) T321EQ5DNL = T320EQ5DNL.

IF( MISSING(T322EQ5DNL) ) T322EQ5DNL = T321EQ5DNL.

IF( MISSING(T323EQ5DNL) ) T323EQ5DNL = T322EQ5DNL.

IF( MISSING(T324EQ5DNL) ) T324EQ5DNL = T323EQ5DNL.

*--------------------------------------------------.

* New block (325-329).

*--------------------------------------------------.

IF( MISSING(T326EQ5DNL) ) T326EQ5DNL = T325EQ5DNL.

IF( MISSING(T327EQ5DNL) ) T327EQ5DNL = T326EQ5DNL.

IF( MISSING(T328EQ5DNL) ) T328EQ5DNL = T327EQ5DNL.

IF( MISSING(T329EQ5DNL) ) T329EQ5DNL = T328EQ5DNL.

*--------------------------------------------------.

* New block (330-334).

*--------------------------------------------------.

IF( MISSING(T331EQ5DNL) ) T331EQ5DNL = T330EQ5DNL.

IF( MISSING(T332EQ5DNL) ) T332EQ5DNL = T331EQ5DNL.

IF( MISSING(T333EQ5DNL) ) T333EQ5DNL = T332EQ5DNL.

IF( MISSING(T334EQ5DNL) ) T334EQ5DNL = T333EQ5DNL.

*--------------------------------------------------.

* New block (335-339).

*--------------------------------------------------.

IF( MISSING(T336EQ5DNL) ) T336EQ5DNL = T335EQ5DNL.

IF( MISSING(T337EQ5DNL) ) T337EQ5DNL = T336EQ5DNL.

IF( MISSING(T338EQ5DNL) ) T338EQ5DNL = T337EQ5DNL.

IF( MISSING(T339EQ5DNL) ) T339EQ5DNL = T338EQ5DNL.

*--------------------------------------------------.

* New block (340-344).

*--------------------------------------------------.

IF( MISSING(T341EQ5DNL) ) T341EQ5DNL = T340EQ5DNL.

IF( MISSING(T342EQ5DNL) ) T342EQ5DNL = T341EQ5DNL.

IF( MISSING(T343EQ5DNL) ) T343EQ5DNL = T342EQ5DNL.

IF( MISSING(T344EQ5DNL) ) T344EQ5DNL = T343EQ5DNL.

*--------------------------------------------------.

* New block (345-349).

*--------------------------------------------------.

IF( MISSING(T346EQ5DNL) ) T346EQ5DNL = T345EQ5DNL.

IF( MISSING(T347EQ5DNL) ) T347EQ5DNL = T346EQ5DNL.

IF( MISSING(T348EQ5DNL) ) T348EQ5DNL = T347EQ5DNL.

IF( MISSING(T349EQ5DNL) ) T349EQ5DNL = T348EQ5DNL.

*--------------------------------------------------.

* New block (350-354).

*--------------------------------------------------.

IF( MISSING(T351EQ5DNL) ) T351EQ5DNL = T350EQ5DNL.

IF( MISSING(T352EQ5DNL) ) T352EQ5DNL = T351EQ5DNL.

IF( MISSING(T353EQ5DNL) ) T353EQ5DNL = T352EQ5DNL.

IF( MISSING(T354EQ5DNL) ) T354EQ5DNL = T353EQ5DNL.

*--------------------------------------------------.

* New block (355-359).

*--------------------------------------------------.

IF( MISSING(T356EQ5DNL) ) T356EQ5DNL = T355EQ5DNL.

IF( MISSING(T357EQ5DNL) ) T357EQ5DNL = T356EQ5DNL.

IF( MISSING(T358EQ5DNL) ) T358EQ5DNL = T357EQ5DNL.

IF( MISSING(T359EQ5DNL) ) T359EQ5DNL = T358EQ5DNL.

*--------------------------------------------------.

* New block (360-364).

*--------------------------------------------------.

IF( MISSING(T361EQ5DNL) ) T361EQ5DNL = T360EQ5DNL.

IF( MISSING(T362EQ5DNL) ) T362EQ5DNL = T361EQ5DNL.

IF( MISSING(T363EQ5DNL) ) T363EQ5DNL = T362EQ5DNL.

IF( MISSING(T364EQ5DNL) ) T364EQ5DNL = T363EQ5DNL.

*--------------------------------------------------.

* New block (365-369).

*--------------------------------------------------.

IF( MISSING(T366EQ5DNL) ) T366EQ5DNL = T365EQ5DNL.

IF( MISSING(T367EQ5DNL) ) T367EQ5DNL = T366EQ5DNL.

IF( MISSING(T368EQ5DNL) ) T368EQ5DNL = T367EQ5DNL.

IF( MISSING(T369EQ5DNL) ) T369EQ5DNL = T368EQ5DNL.

*--------------------------------------------------.

* New block (370-374).

*--------------------------------------------------.

IF( MISSING(T371EQ5DNL) ) T371EQ5DNL = T370EQ5DNL.

IF( MISSING(T372EQ5DNL) ) T372EQ5DNL = T371EQ5DNL.

IF( MISSING(T373EQ5DNL) ) T373EQ5DNL = T372EQ5DNL.

IF( MISSING(T374EQ5DNL) ) T374EQ5DNL = T373EQ5DNL.

*--------------------------------------------------.

* New block (375-379).

*--------------------------------------------------.

IF( MISSING(T376EQ5DNL) ) T376EQ5DNL = T375EQ5DNL.

IF( MISSING(T377EQ5DNL) ) T377EQ5DNL = T376EQ5DNL.

IF( MISSING(T378EQ5DNL) ) T378EQ5DNL = T377EQ5DNL.

IF( MISSING(T379EQ5DNL) ) T379EQ5DNL = T378EQ5DNL.

*--------------------------------------------------.

* New block (380-384).

*--------------------------------------------------.

IF( MISSING(T381EQ5DNL) ) T381EQ5DNL = T380EQ5DNL.

IF( MISSING(T382EQ5DNL) ) T382EQ5DNL = T381EQ5DNL.

IF( MISSING(T383EQ5DNL) ) T383EQ5DNL = T382EQ5DNL.

IF( MISSING(T384EQ5DNL) ) T384EQ5DNL = T383EQ5DNL.

*--------------------------------------------------.

* New block (385-389).

*--------------------------------------------------.

IF( MISSING(T386EQ5DNL) ) T386EQ5DNL = T385EQ5DNL.

IF( MISSING(T387EQ5DNL) ) T387EQ5DNL = T386EQ5DNL.

IF( MISSING(T388EQ5DNL) ) T388EQ5DNL = T387EQ5DNL.

IF( MISSING(T389EQ5DNL) ) T389EQ5DNL = T388EQ5DNL.

*--------------------------------------------------.

* New block (390-394).

*--------------------------------------------------.

IF( MISSING(T391EQ5DNL) ) T391EQ5DNL = T390EQ5DNL.

IF( MISSING(T392EQ5DNL) ) T392EQ5DNL = T391EQ5DNL.

IF( MISSING(T393EQ5DNL) ) T393EQ5DNL = T392EQ5DNL.

IF( MISSING(T394EQ5DNL) ) T394EQ5DNL = T393EQ5DNL.

*--------------------------------------------------.

* New block (395-399).

*--------------------------------------------------.

IF( MISSING(T396EQ5DNL) ) T396EQ5DNL = T395EQ5DNL.

IF( MISSING(T397EQ5DNL) ) T397EQ5DNL = T396EQ5DNL.

IF( MISSING(T398EQ5DNL) ) T398EQ5DNL = T397EQ5DNL.

IF( MISSING(T399EQ5DNL) ) T399EQ5DNL = T398EQ5DNL.


Cheers!!
Albert-Jan

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
All right, but apart from the sanitation, the medicine, education, wine, public order, irrigation, roads, a fresh water system, and public health, what have the Romans ever done for us?
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

--- On Thu, 7/14/11, maartjegoorden <[hidden email]> wrote:

From: maartjegoorden <[hidden email]>
Subject: [SPSSX-L] Somebody who knows much about macros???
To: [hidden email]
Date: Thursday, July 14, 2011, 3:12 PM

Hello! I am pretty new at spss macro's, but I think I need one.

I have 400 variables, I want to do this loop 400 times.  My variables are
ordered consecutively. Who can help me ? So first I want to do this loop for
variables 1 to 4, than for variables 5 to 8, than for variables 8 to 12 and
so on.

vector TEQ5DBv=T0EQ5DNL to T4EQ5DNL.
loop #index = 1 to 4.
+ IF( MISSING(TEQ5DBv(#index+1))) TEQ5DBv(#index+1) = TEQ5DBv(#index) .
end loop .
EXECUTE .

Thank you very much!

Greetings maartje

--
View this message in context: http://spssx-discussion.1045642.n5.nabble.com/Somebody-who-knows-much-about-macros-tp4586587p4586587.html
Sent from the SPSSX Discussion mailing list archive at Nabble.com.

=====================
To manage your subscription to SPSSX-L, send a message to
LISTSERV@... (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
Reply | Threaded
Open this post in threaded view
|

Re: Somebody who knows much about macros???

Bruce Weaver
Administrator
In reply to this post by maartjegoorden
Does this do what you want?

vector TEQ5DBv=T0EQ5DNL to LastVar. /* LastVar = name of 400th variable.
loop #i = 0 to 396 by 4.
loop #j = 1 to 4.
+ compute #index = #i + #j.
+ IF( MISSING(TEQ5DBv(#index+1))) TEQ5DBv(#index+1) = TEQ5DBv(#index) .
end loop .
end loop.
EXECUTE .


maartjegoorden wrote
Hello! I am pretty new at spss macro's, but I think I need one.

I have 400 variables, I want to do this loop 400 times.  My variables are ordered consecutively. Who can help me ? So first I want to do this loop for variables 1 to 4, than for variables 5 to 8, than for variables 8 to 12 and so on.

vector TEQ5DBv=T0EQ5DNL to T4EQ5DNL.
loop #index = 1 to 4.
+ IF( MISSING(TEQ5DBv(#index+1))) TEQ5DBv(#index+1) = TEQ5DBv(#index) .
end loop .
EXECUTE .

Thank you very much!

Greetings maartje
--
Bruce Weaver
bweaver@lakeheadu.ca
http://sites.google.com/a/lakeheadu.ca/bweaver/

"When all else fails, RTFM."

PLEASE NOTE THE FOLLOWING: 
1. My Hotmail account is not monitored regularly. To send me an e-mail, please use the address shown above.
2. The SPSSX Discussion forum on Nabble is no longer linked to the SPSSX-L listserv administered by UGA (https://listserv.uga.edu/).
Reply | Threaded
Open this post in threaded view
|

Re: Somebody who knows much about macros???

David Marso
Administrator
In reply to this post by maartjegoorden
Question:  Say your vars are called V001 TO V400 rather than what you are calling them (no way to know on our end what to call them).
If V005 is missing then do you wish to replace it with the value of V004?
If so then why are you breaking it up into ...variables 1 to 4, than for variables 5 to 8 (just Loop from 1 to 400)?
If not then what value should the first variable in each of the 100 sets take?

maartjegoorden wrote
Hello! I am pretty new at spss macro's, but I think I need one.

I have 400 variables, I want to do this loop 400 times.  My variables are ordered consecutively. Who can help me ? So first I want to do this loop for variables 1 to 4, than for variables 5 to 8, than for variables 8 to 12 and so on.

vector TEQ5DBv=T0EQ5DNL to T4EQ5DNL.
loop #index = 1 to 4.
+ IF( MISSING(TEQ5DBv(#index+1))) TEQ5DBv(#index+1) = TEQ5DBv(#index) .
end loop .
EXECUTE .

Thank you very much!

Greetings maartje
Please reply to the list and not to my personal email.
Those desiring my consulting or training services please feel free to email me.
---
"Nolite dare sanctum canibus neque mittatis margaritas vestras ante porcos ne forte conculcent eas pedibus suis."
Cum es damnatorum possederunt porcos iens ut salire off sanguinum cliff in abyssum?"
Reply | Threaded
Open this post in threaded view
|

Re: Somebody who knows much about macros???

David Marso
Administrator
In reply to this post by Bruce Weaver
Doesn't this do the same thing as:
LOOP #=1 To 400.
If MISSING(TEQ5DBv(#+1) ) TEQ5DBv(#+1)=TEQ5DBv(#).
END LOOP.
Check boundary conditions -It will run off the edge when #=400-

Bruce Weaver wrote
Does this do what you want?

vector TEQ5DBv=T0EQ5DNL to LastVar. /* LastVar = name of 400th variable.
loop #i = 0 to 396 by 4.
loop #j = 1 to 4.
+ compute #index = #i + #j.
+ IF( MISSING(TEQ5DBv(#index+1))) TEQ5DBv(#index+1) = TEQ5DBv(#index) .
end loop .
end loop.
EXECUTE .


maartjegoorden wrote
Hello! I am pretty new at spss macro's, but I think I need one.

I have 400 variables, I want to do this loop 400 times.  My variables are ordered consecutively. Who can help me ? So first I want to do this loop for variables 1 to 4, than for variables 5 to 8, than for variables 8 to 12 and so on.

vector TEQ5DBv=T0EQ5DNL to T4EQ5DNL.
loop #index = 1 to 4.
+ IF( MISSING(TEQ5DBv(#index+1))) TEQ5DBv(#index+1) = TEQ5DBv(#index) .
end loop .
EXECUTE .

Thank you very much!

Greetings maartje
Please reply to the list and not to my personal email.
Those desiring my consulting or training services please feel free to email me.
---
"Nolite dare sanctum canibus neque mittatis margaritas vestras ante porcos ne forte conculcent eas pedibus suis."
Cum es damnatorum possederunt porcos iens ut salire off sanguinum cliff in abyssum?"
Reply | Threaded
Open this post in threaded view
|

Re: Somebody who knows much about macros???

David Marso
Administrator
In reply to this post by Albert-Jan Roskam
WOW!  This is so much easier to understand than the simple VECTOR/LOOP ;-)
GACK!  Albert-Jan.  Sometimes Python has its place (eg requiring dictionary info/data cursors etc), but this is probably one of those everything looks like a nail when you have a hammer situations.

>BEGIN PROGRAM.
>import os
>import spss
>sep = os.linesep
>cmds = ""
>for n in range(0, 400):
>    if n > 0 and n % 5 != 0:
>        cmd = "IF( MISSING(T%dEQ5DNL) ) T%dEQ5DNL = T%dEQ5DNL.%s" % (n, n, n-1, sep)
>    else:
>        cmd = "*" + 50 * "-" + ".%s* New block (%d-%d).%s" % (sep, n, n+4, sep) + "*" + 50 * "-" + >".%s" % sep
>    cmds += cmd
>spss.Submit(cmds)
>END PROGRAM.
Please reply to the list and not to my personal email.
Those desiring my consulting or training services please feel free to email me.
---
"Nolite dare sanctum canibus neque mittatis margaritas vestras ante porcos ne forte conculcent eas pedibus suis."
Cum es damnatorum possederunt porcos iens ut salire off sanguinum cliff in abyssum?"
Reply | Threaded
Open this post in threaded view
|

Re: Somebody who knows much about macros???

Albert-Jan Roskam
:-)) Perhaps you're right, but most of the clunky code is in the comment (which is not generated with the pure-syntax loop. Also, the pure-syntax code Bruce posted has two loops, with the busiest loop being the outer loop. I wonder which code is faster (not that it matters if it's just a few ms ;-).

Cheers!!
Albert-Jan

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
All right, but apart from the sanitation, the medicine, education, wine, public order, irrigation, roads, a fresh water system, and public health, what have the Romans ever done for us?
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

--- On Thu, 7/14/11, David Marso <[hidden email]> wrote:

From: David Marso <[hidden email]>
Subject: Re: [SPSSX-L] Somebody who knows much about macros???
To: [hidden email]
Date: Thursday, July 14, 2011, 7:04 PM

WOW!  This is so much easier to understand than the simple VECTOR/LOOP ;-)
GACK!  Albert-Jan.  Sometimes Python has its place (eg requiring dictionary
info/data cursors etc), but this is probably one of those everything looks
like a nail when you have a hammer situations.

>BEGIN PROGRAM.
>import os
>import spss
>sep = os.linesep
>cmds = ""
>for n in range(0, 400):
>    if n > 0 and n % 5 != 0:
>        cmd = "IF( MISSING(T%dEQ5DNL) ) T%dEQ5DNL = T%dEQ5DNL.%s" % (n, n,
> n-1, sep)
>    else:
>        cmd = "*" + 50 * "-" + ".%s* New block (%d-%d).%s" % (sep, n, n+4,
> sep) + "*" + 50 * "-" + >".%s" % sep
>    cmds += cmd
>spss.Submit(cmds)
>END PROGRAM.

--
View this message in context: http://spssx-discussion.1045642.n5.nabble.com/Somebody-who-knows-much-about-macros-tp4586587p4587482.html
Sent from the SPSSX Discussion mailing list archive at Nabble.com.

=====================
To manage your subscription to SPSSX-L, send a message to
LISTSERV@... (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
Reply | Threaded
Open this post in threaded view
|

Re: Somebody who knows much about macros???

Bruce Weaver
Administrator
In reply to this post by David Marso
Yes, of course it does.  I don't suppose you'd believe I was just testing you, would you?  :-|

But that makes me wonder what the OP was getting at when they said, "...first I want to do this loop for variables 1 to 4, than for variables 5 to 8, than for variables 8 to 12 and so on."  Does that mean that the loop should only look at variable(#+1) provided # is less than 4?  I.e., they want to carry values forward, but only within groups of 4 variables.  Something like:

data list list / v1 to v8 (8f2.0).
begin data
1 2 3 4 1 2 3 4
1 2 3 9 1 2 3 9
1 2 9 9 1 2 9 9
1 9 9 9 1 9 9 9
1 2 3 4 9 2 3 4
9 2 3 4 9 2 3 4
end data.

missing values all(9).
list. /* Before processing.

vector v = v1 to v8.
loop #i = 1 to 8.
- compute #TheLastVar =  mod(#i,4) EQ 0.
- DO IF not #TheLastVar.
-   IF ( MISSING(v(#i+1))) v(#i+1) = v(#i) .
- END IF.
end loop .
EXECUTE .
list. /* After processing.


Output before processing (9 is Missing):

v1 v2 v3 v4 v5 v6 v7 v8

 1  2  3  4  1  2  3  4
 1  2  3  9  1  2  3  9
 1  2  9  9  1  2  9  9
 1  9  9  9  1  9  9  9
 1  2  3  4  9  2  3  4
 9  2  3  4  9  2  3  4

Output after processing:

v1 v2 v3 v4 v5 v6 v7 v8

 1  2  3  4  1  2  3  4
 1  2  3  3  1  2  3  3
 1  2  2  2  1  2  2  2
 1  1  1  1  1  1  1  1
 1  2  3  4  9  2  3  4
 9  2  3  4  9  2  3  4

Notice that the value of v5 (the first variable in the 2nd group of 4) remains missing, rather than having the valid values from v4 carried forward.  

This now makes me wonder if the OP is trying to to "last observation carried forward" imputation (LOCF).  If so, that method is not highly regarded these days.  There are many articles on it, including a very readable one by David Streiner.  

   http://ebmh.bmj.com/content/11/1/3.2.short

HTH.


David Marso wrote
Doesn't this do the same thing as:
LOOP #=1 To 400.
If MISSING(TEQ5DBv(#+1) ) TEQ5DBv(#+1)=TEQ5DBv(#).
END LOOP.
Check boundary conditions -It will run off the edge when #=400-

Bruce Weaver wrote
Does this do what you want?

vector TEQ5DBv=T0EQ5DNL to LastVar. /* LastVar = name of 400th variable.
loop #i = 0 to 396 by 4.
loop #j = 1 to 4.
+ compute #index = #i + #j.
+ IF( MISSING(TEQ5DBv(#index+1))) TEQ5DBv(#index+1) = TEQ5DBv(#index) .
end loop .
end loop.
EXECUTE .


maartjegoorden wrote
Hello! I am pretty new at spss macro's, but I think I need one.

I have 400 variables, I want to do this loop 400 times.  My variables are ordered consecutively. Who can help me ? So first I want to do this loop for variables 1 to 4, than for variables 5 to 8, than for variables 8 to 12 and so on.

vector TEQ5DBv=T0EQ5DNL to T4EQ5DNL.
loop #index = 1 to 4.
+ IF( MISSING(TEQ5DBv(#index+1))) TEQ5DBv(#index+1) = TEQ5DBv(#index) .
end loop .
EXECUTE .

Thank you very much!

Greetings maartje
--
Bruce Weaver
bweaver@lakeheadu.ca
http://sites.google.com/a/lakeheadu.ca/bweaver/

"When all else fails, RTFM."

PLEASE NOTE THE FOLLOWING: 
1. My Hotmail account is not monitored regularly. To send me an e-mail, please use the address shown above.
2. The SPSSX Discussion forum on Nabble is no longer linked to the SPSSX-L listserv administered by UGA (https://listserv.uga.edu/).
Reply | Threaded
Open this post in threaded view
|

Re: Somebody who knows much about macros???

David Marso
Administrator
"I don't suppose you'd believe I was just testing you, would you?  :-|"
Sure.... ;-)
"There are many articles on it, including a very readable one by David Streiner.  
   http://ebmh.bmj.com/content/11/1/3.2.short "
That looks interesting (the abstract that is).  Wish I had access to it.
(Lucky you academics are possible to email me the pdf?).
--
  Assuming that the 'imputation' not cross boundaries something like...
A little more to the point (I try to code directly to the variable being examined.)
in this case we are interested in examining and doing something with a variable
in a given position.  Rather than referencing this as #+1, I prefer to use # and then do replacement on #-1 (note loop begins with 2 rather than 1).
---
VECTOR V=Var001 TO Var400.
LOOP #=2 To 400.
IF (   (MOD(#,4)  NE 1)   AND (MISSING(V(#) )
         V(#)=V(#-1).
END LOOP.

Bruce Weaver wrote
Yes, of course it does.  I don't suppose you'd believe I was just testing you, would you?  :-|

But that makes me wonder what the OP was getting at when they said, "...first I want to do this loop for variables 1 to 4, than for variables 5 to 8, than for variables 8 to 12 and so on."  Does that mean that the loop should only look at variable(#+1) provided # is less than 4?  I.e., they want to carry values forward, but only within groups of 4 variables.  Something like:

data list list / v1 to v8 (8f2.0).
begin data
1 2 3 4 1 2 3 4
1 2 3 9 1 2 3 9
1 2 9 9 1 2 9 9
1 9 9 9 1 9 9 9
1 2 3 4 9 2 3 4
9 2 3 4 9 2 3 4
end data.

missing values all(9).
list. /* Before processing.

vector v = v1 to v8.
loop #i = 1 to 8.
- compute #TheLastVar =  mod(#i,4) EQ 0.
- DO IF not #TheLastVar.
-   IF ( MISSING(v(#i+1))) v(#i+1) = v(#i) .
- END IF.
end loop .
EXECUTE .
list. /* After processing.


Output before processing (9 is Missing):

v1 v2 v3 v4 v5 v6 v7 v8

 1  2  3  4  1  2  3  4
 1  2  3  9  1  2  3  9
 1  2  9  9  1  2  9  9
 1  9  9  9  1  9  9  9
 1  2  3  4  9  2  3  4
 9  2  3  4  9  2  3  4

Output after processing:

v1 v2 v3 v4 v5 v6 v7 v8

 1  2  3  4  1  2  3  4
 1  2  3  3  1  2  3  3
 1  2  2  2  1  2  2  2
 1  1  1  1  1  1  1  1
 1  2  3  4  9  2  3  4
 9  2  3  4  9  2  3  4

Notice that the value of v5 (the first variable in the 2nd group of 4) remains missing, rather than having the valid values from v4 carried forward.  

This now makes me wonder if the OP is trying to to "last observation carried forward" imputation (LOCF).  If so, that method is not highly regarded these days.  There are many articles on it, including a very readable one by David Streiner.  

   http://ebmh.bmj.com/content/11/1/3.2.short

HTH.


David Marso wrote
Doesn't this do the same thing as:
LOOP #=1 To 400.
If MISSING(TEQ5DBv(#+1) ) TEQ5DBv(#+1)=TEQ5DBv(#).
END LOOP.
Check boundary conditions -It will run off the edge when #=400-

Bruce Weaver wrote
Does this do what you want?

vector TEQ5DBv=T0EQ5DNL to LastVar. /* LastVar = name of 400th variable.
loop #i = 0 to 396 by 4.
loop #j = 1 to 4.
+ compute #index = #i + #j.
+ IF( MISSING(TEQ5DBv(#index+1))) TEQ5DBv(#index+1) = TEQ5DBv(#index) .
end loop .
end loop.
EXECUTE .


maartjegoorden wrote
Hello! I am pretty new at spss macro's, but I think I need one.

I have 400 variables, I want to do this loop 400 times.  My variables are ordered consecutively. Who can help me ? So first I want to do this loop for variables 1 to 4, than for variables 5 to 8, than for variables 8 to 12 and so on.

vector TEQ5DBv=T0EQ5DNL to T4EQ5DNL.
loop #index = 1 to 4.
+ IF( MISSING(TEQ5DBv(#index+1))) TEQ5DBv(#index+1) = TEQ5DBv(#index) .
end loop .
EXECUTE .

Thank you very much!

Greetings maartje
Please reply to the list and not to my personal email.
Those desiring my consulting or training services please feel free to email me.
---
"Nolite dare sanctum canibus neque mittatis margaritas vestras ante porcos ne forte conculcent eas pedibus suis."
Cum es damnatorum possederunt porcos iens ut salire off sanguinum cliff in abyssum?"
Reply | Threaded
Open this post in threaded view
|

Re: Somebody who knows much about macros???

Bruce Weaver
Administrator
Yep, that's a bit neater.  Thanks David.  It's still not clear whether that's what the OP wanted, of course.  ;-)

I'll send you that Streiner article.

bw


David Marso wrote
"I don't suppose you'd believe I was just testing you, would you?  :-|"
Sure.... ;-)
"There are many articles on it, including a very readable one by David Streiner.  
   http://ebmh.bmj.com/content/11/1/3.2.short "
That looks interesting (the abstract that is).  Wish I had access to it.
(Lucky you academics are possible to email me the pdf?).
--
  Assuming that the 'imputation' not cross boundaries something like...
A little more to the point (I try to code directly to the variable being examined.)
in this case we are interested in examining and doing something with a variable
in a given position.  Rather than referencing this as #+1, I prefer to use # and then do replacement on #-1 (note loop begins with 2 rather than 1).
---
VECTOR V=Var001 TO Var400.
LOOP #=2 To 400.
IF (   (MOD(#,4)  NE 1)   AND (MISSING(V(#) )
         V(#)=V(#-1).
END LOOP.

Bruce Weaver wrote
Yes, of course it does.  I don't suppose you'd believe I was just testing you, would you?  :-|

But that makes me wonder what the OP was getting at when they said, "...first I want to do this loop for variables 1 to 4, than for variables 5 to 8, than for variables 8 to 12 and so on."  Does that mean that the loop should only look at variable(#+1) provided # is less than 4?  I.e., they want to carry values forward, but only within groups of 4 variables.  Something like:

data list list / v1 to v8 (8f2.0).
begin data
1 2 3 4 1 2 3 4
1 2 3 9 1 2 3 9
1 2 9 9 1 2 9 9
1 9 9 9 1 9 9 9
1 2 3 4 9 2 3 4
9 2 3 4 9 2 3 4
end data.

missing values all(9).
list. /* Before processing.

vector v = v1 to v8.
loop #i = 1 to 8.
- compute #TheLastVar =  mod(#i,4) EQ 0.
- DO IF not #TheLastVar.
-   IF ( MISSING(v(#i+1))) v(#i+1) = v(#i) .
- END IF.
end loop .
EXECUTE .
list. /* After processing.


Output before processing (9 is Missing):

v1 v2 v3 v4 v5 v6 v7 v8

 1  2  3  4  1  2  3  4
 1  2  3  9  1  2  3  9
 1  2  9  9  1  2  9  9
 1  9  9  9  1  9  9  9
 1  2  3  4  9  2  3  4
 9  2  3  4  9  2  3  4

Output after processing:

v1 v2 v3 v4 v5 v6 v7 v8

 1  2  3  4  1  2  3  4
 1  2  3  3  1  2  3  3
 1  2  2  2  1  2  2  2
 1  1  1  1  1  1  1  1
 1  2  3  4  9  2  3  4
 9  2  3  4  9  2  3  4

Notice that the value of v5 (the first variable in the 2nd group of 4) remains missing, rather than having the valid values from v4 carried forward.  

This now makes me wonder if the OP is trying to to "last observation carried forward" imputation (LOCF).  If so, that method is not highly regarded these days.  There are many articles on it, including a very readable one by David Streiner.  

   http://ebmh.bmj.com/content/11/1/3.2.short

HTH.


David Marso wrote
Doesn't this do the same thing as:
LOOP #=1 To 400.
If MISSING(TEQ5DBv(#+1) ) TEQ5DBv(#+1)=TEQ5DBv(#).
END LOOP.
Check boundary conditions -It will run off the edge when #=400-

Bruce Weaver wrote
Does this do what you want?

vector TEQ5DBv=T0EQ5DNL to LastVar. /* LastVar = name of 400th variable.
loop #i = 0 to 396 by 4.
loop #j = 1 to 4.
+ compute #index = #i + #j.
+ IF( MISSING(TEQ5DBv(#index+1))) TEQ5DBv(#index+1) = TEQ5DBv(#index) .
end loop .
end loop.
EXECUTE .


maartjegoorden wrote
Hello! I am pretty new at spss macro's, but I think I need one.

I have 400 variables, I want to do this loop 400 times.  My variables are ordered consecutively. Who can help me ? So first I want to do this loop for variables 1 to 4, than for variables 5 to 8, than for variables 8 to 12 and so on.

vector TEQ5DBv=T0EQ5DNL to T4EQ5DNL.
loop #index = 1 to 4.
+ IF( MISSING(TEQ5DBv(#index+1))) TEQ5DBv(#index+1) = TEQ5DBv(#index) .
end loop .
EXECUTE .

Thank you very much!

Greetings maartje
--
Bruce Weaver
bweaver@lakeheadu.ca
http://sites.google.com/a/lakeheadu.ca/bweaver/

"When all else fails, RTFM."

PLEASE NOTE THE FOLLOWING: 
1. My Hotmail account is not monitored regularly. To send me an e-mail, please use the address shown above.
2. The SPSSX Discussion forum on Nabble is no longer linked to the SPSSX-L listserv administered by UGA (https://listserv.uga.edu/).
Reply | Threaded
Open this post in threaded view
|

Re: Somebody who knows much about macros???

maartjegoorden
Thank you for all your responses, I didn't see them, I thought I would get a notice but I didn't. Eventually I found out myself, that LOCF was not a good imputation method (I tried to do that yeah)  But thank you all!!

Greetings maartje