|
Hello,
I have simple python syntax: begin program. import spss strq19="" for i in range(1,40): for j in range (1,5): strq19= strq19 + "if q19_"+ str(i) + "_" + str(j) + "=1 or q19_"+ str(i) + "_" + str(j) + "=5 xq19_" + str(i) + "=1.\n" spss.Submit(strq19) end program. When executing I got a message (but variables are created!): ================ [...] 2925 0 M> if q19_38_4=1 or q19_38_4=5 xq19_38=1. 2926 0 M> if q19_39_1=1 or q19_39_1=5 xq19_39=1. 2927 0 M> if q19_39_2=1 or q19_39_2=5 xq19_39=1. 2928 0 M> if q19_39_3=1 or q19_39_3=5 xq19_39=1. 2929 0 M> if q19_39_4=1 or q19_39_4=5 xq19_39=1. 2930 0 M> BEGIN PROGRAM '# '. Traceback (most recent call last): File "<string>", line 8, in <module> File "C:\Python25\lib\site-packages\spss170\spss\spss.py", line 1265, in Submit raise SpssError,error spss.errMsg.SpssError: [errLevel 3] Serious error. ================ This is SPSS v17.0.1 with original installed python2.5. Has anybody met such error? Regards, Piotr -- Piotr Kolodziejczyk Production Manager Consumer Research, Poland The Nielsen Company ===================== 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 |
|
Hi!
Not sure if you need the newline character. Also, the Submit should be in the inner loop. And if the IF statement is a multiline-statement, you should indicate this with a backslash. begin program. import spss for i in range(1,40): for j in range (1,5): var1 = "q19_"+ str(i) + "_" + str(j) var2 = "q19_" + str(i) + "_" + str(j) var3 = "xq19_" + str(i) spss.Submit("if (%s = 1 or %s = 5) %s = 1." % (var1, var2, var3)) end program. Cheers!! Albert-Jan --- On Thu, 4/23/09, Kolodziejczyk, Piotr <[hidden email]> wrote: > From: Kolodziejczyk, Piotr <[hidden email]> > Subject: python syntax error? > To: [hidden email] > Date: Thursday, April 23, 2009, 6:16 PM > Hello, > > I have simple python syntax: > > begin program. > import spss > strq19="" > for i in range(1,40): > for j in range (1,5): > strq19= strq19 + "if > q19_"+ str(i) + "_" + str(j) + "=1 or > q19_"+ str(i) + "_" + str(j) + "=5 xq19_" + str(i) + > "=1.\n" > spss.Submit(strq19) > end program. > > When executing I got a message (but variables are > created!): > ================ > [...] > 2925 0 M> if q19_38_4=1 or q19_38_4=5 xq19_38=1. > 2926 0 M> if q19_39_1=1 or q19_39_1=5 xq19_39=1. > 2927 0 M> if q19_39_2=1 or q19_39_2=5 xq19_39=1. > 2928 0 M> if q19_39_3=1 or q19_39_3=5 xq19_39=1. > 2929 0 M> if q19_39_4=1 or q19_39_4=5 xq19_39=1. > 2930 0 M> BEGIN PROGRAM '# > '. > > Traceback (most recent call last): > File "<string>", line 8, in <module> > File "C:\Python25\lib\site-packages\spss170\spss\spss.py", > line 1265, in > Submit > raise SpssError,error > spss.errMsg.SpssError: [errLevel 3] Serious error. > ================ > > This is SPSS v17.0.1 with original installed python2.5. > Has anybody met such error? > > Regards, > Piotr > > > -- > Piotr Kolodziejczyk > Production Manager > Consumer Research, Poland > The Nielsen Company > > ===================== > 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 > ===================== 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 |
| Free forum by Nabble | Edit this page |
