Save Outfile with Python Loop in SPSS
Question: Ok so I've been playing with python and spss to achieve almost what I want. I
am able to open the file and make the changes, however I am having trouble
saving the files (and those changes). What I have (using only one school in
the `schoollist`):

    
    
    begin program.
    import spss, spssaux
    import os
    schoollist = ['brow']
    for x in schoollist:
       school = 'brow'
       school2 = school + '06.sav'
       filename = os.path.join("Y:\...\Data", school2) #In this instance, Y:\...\Data\brow06.sav
       spssaux.OpenDataFile(filename)
    
       #--This block are the changes and not particularly relevant to the question--#
       cur=spss.Cursor(accessType='w')
       cur.SetVarNameAndType(['name'],[8])
       cur.CommitDictionary()
       for i in range(cur.GetCaseCount()):
          cur.fetchone()
          cur.SetValueChar('name', school)
          cur.CommitCase()
       cur.close()
    
       #-- What am I doing wrong here? --#
       spss.Submit("save outfile = filename".)
    
    end program.
    

Any suggestions on how to get the `save outfile` to work with the loop?
Thanks. Cheers


Answer: In your save call, you are not resolving filename to its actual value. It
should be something like this: spss.Submit("""save outfile="%s".""" %
filename)

