f



running python program in macro

Hey all,

I have a macro that has been broken for a while and I am finally getting 
around to updating.

I am using a macro from Raynald's page that get's all combinations from 
a set of variables and writes to a file.

What I am trying to do is take this file and, using python to reopen the
file add some lines to the bottom of this file.  The python program runs
fine on it's own but when I put it inside the macro it stops running. 
My guess is that the "END PROGRAM" is terminating the macro.  Any 
solutions to this?

TIA,

Lance


DEFINE !combine (n=!TOKENS(1)     /* N = COMBINATIONS */
                 /items=!CMDEND).  /* ITEMS = LIST OF ITEMS */


/* Find all combinations of n items out of m items*/
/* Sept 11,2001 rlevesque@videotron.ca */


* Count number of variables.
!LET !nb=!NULL
!DO !cnt !IN (!items)
!LET !nb=!CONCAT(!nb,!BLANK(1))
!DOEND
!LET !m=!LENGTH(!nb)


***
***
***
***

* Write the syntax file which will call the macro for each desired
	combination of variables.

WRITE OUTFILE='c:\temp\mymacro.sps'  /"GET FILE = '" !DATA !DATAFILE "'."
                                      /'!discrim 'items'.'.
EXECUTE.




BEGIN PROGRAM.
text_file = open("c:/temp/mymacro.sps", "a")
lines = ["GET FILE='C:\TEMP\percents.sav' /drop=TOTAL.\n"
          "MATCH FILES /FILE = *\n"
          "/FILE='C:\TEMP\VARS.sav'\n"
          "/DROP j1 to first.\n"
          "EXE."]
text_file.writelines(lines)
text_file.close()
END PROGRAM.

!ENDDEFINE.


0
Lance
10/29/2009 2:07:37 PM
comp.soft-sys.stat.spss 5679 articles. 0 followers. Post Follow

0 Replies
662 Views

Similar Articles

[PageSpeed] 52

Reply: