I’m using a python program to generate data for teaching purposes (it’s the statsgeneratedata routine Jon mentioned to me last year). I’m trying to pass a value representing the desired population size to the program. I’m doing this partially because I’m running the program multiple times and I’m wanting to create syntax where I can set the desired population size once and use the same value several times (the full reason will take too long to explain). I can successfully do this: define !PopulationSize() 5000 !enddefine. But passing that constant to the program below doesn’t work. begin program. import statsgeneratedata numvar = 6 numcase = !PopulationSize << Here’s the problem parms = "0 5 " dsname = "X" factor = "factor" corrtype = "ARBITRARY" corrs = "1 0 1 0 0 1 0 0 0 1 0 0 0 0 1 0 0 0 0 0 1" displaycorr="noprint" distribution = "NORMAL" displayinputpgm = "noprint" statsgeneratedata.generate(dsname, numvar, numcase, distribution, parms, factor, corrtype, corrs, displaycorr, displayinputpgm) end program. Is there some way to pass a value to a python program so that this will work? Best, Jeff |
The best way to do this is to use the SPSSINC PROGRAM extension command to run this. It takes a module/function name and a list of named arguments. From the syntax help: SPSSINC PROGRAM programname* arguments example:
programname specifies the Python function to be run. It has the form modulename.functionname or, if already defined in the current session, it can just be functionname. Note that modulename and functionname are case sensitive. arguments. The argument values depend on the particular program being run. You would typically save the program as a Python module stored anywhere that Python can find it. The details on how to write the program so that this works are in the syntax help. I can help you with that if you specify which parameters you want to expose this way. On Wed, Feb 12, 2020 at 11:26 PM Jeff A <[hidden email]> wrote:
|
Free forum by Nabble | Edit this page |