Dear all,
The following code is correct but is not mprinted back properly. set mpr on. begin program. dir='d:/t1/' import spss for filno in [str(i) for i in range(3)]: spss.Submit(""" data list free/id. begin data %(filno)s end data."""%locals()) end program. yields 854 0 M> data list free/id. 855 0 M> begin data 856 0 M> end data. >Warning # 9. Command name: end data >An END DATA command appears where it is not required. It will be ignored. First: where did "filno" (line 8) go? Second: why do I get this warning? "end data." is needed all right here. When I add a bit more code, the result gets even weirder. begin program. dir='d:/t1/' import spss for filno in [str(i) for i in range(3)]: spss.Submit(""" data list free/id. begin data %(filno)s end data. sav out "%(dir)sfile_%(filno)s.sav"."""%locals()) end program. yields 878 0 M> data list free/id. 879 0 M> begin data 880 0 M> sav out "d:/t1/file_0.sav". 881 0 M> BEGIN PROGRAM '# '. This code runs fine and gives no more warnings but nevertheless two lines that should be mprinted aren't. Is this a bug? Could anybody explain what's going on here? TIA! Ruben |
There are some tricky things that happen
when processing multi-line Submit calls, especially with the call containing
a mode switch to text that is not actually a command. Your code is
actually working. If you change data list free to data list list,
you don't get the error message.
Jon Peck (no "h") aka Kim Senior Software Engineer, IBM [hidden email] new phone: 720-342-5621 From: Ruben van den Berg <[hidden email]> To: [hidden email] Date: 10/04/2012 03:35 AM Subject: [SPSSX-L] Weird behavior "data list" command in Python block Sent by: "SPSSX(r) Discussion" <[hidden email]> Dear all, The following code is correct but is not mprinted back properly. set mpr on. begin program. dir='d:/t1/' import spss for filno in [str(i) for i in range(3)]: spss.Submit(""" data list free/id. begin data %(filno)s end data."""%locals()) end program. yields 854 0 M> data list free/id. 855 0 M> begin data 856 0 M> end data. >Warning # 9. Command name: end data >An END DATA command appears where it is not required. It will be ignored. First: where did "filno" (line 8) go? Second: why do I get this warning? "end data." is needed all right here. When I add a bit more code, the result gets even weirder. begin program. dir='d:/t1/' import spss for filno in [str(i) for i in range(3)]: spss.Submit(""" data list free/id. begin data %(filno)s end data. sav out "%(dir)sfile_%(filno)s.sav"."""%locals()) end program. yields 878 0 M> data list free/id. 879 0 M> begin data 880 0 M> sav out "d:/t1/file_0.sav". 881 0 M> BEGIN PROGRAM '# '. This code runs fine and gives no more warnings but nevertheless two lines that should be mprinted aren't. Is this a bug? Could anybody explain what's going on here? TIA! Ruben |
Free forum by Nabble | Edit this page |