Problem with Include and Python

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Problem with Include and Python

Cleland, Patricia (EDU)
Listers,

I have some SPSS syntax called DisplayDictionary2(Python).sps that
sucessully generates a data dictionary using Python when I open the
syntax and do Run All.

However, when I try to INCLUDE the syntax in a master syntax file (using
the command
INCLUDE 'U:\SPSS\Python\DisplayDictionary2(Python).SPS'.).  I get the
following error message:  


  17  BEGIN PROGRAM.
  19  import spss, spssaux, DisplayDict2
  20  print "Data Dictionary for:", spssaux.GetDatasetInfo()
  21  print "Number of Variables:", spss.GetVariableCount()
  22  DisplayDict2.dictionary(measlevel=False)
Data Dictionary for:
Traceback (most recent call last):
  File "<string>", line 1, in ?
NameError: name 'spssaux' is not defined
  22  END PROGRAM.
  23  
  24  
  25  * End of INSERT and INCLUDE nesting level 01.

>Error # 5712 in column 8.  Text: spss

>A valid IMPORT subcommand name is expected but not found.  Recognized
>subcommands are FILE, TYPE, KEEP, DROP, RENAME, and MAP.
>This command not executed.

Is it possible to INCLUDE this kind of syntax?

Pat
Reply | Threaded
Open this post in threaded view
|

Re: Problem with Include and Python

Peck, Jon
You need to use the INSERT command instead of INCLUDE.

Say
INSERT file=filespec.

-Jon Peck
SPSS

-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Cleland, Patricia (EDU)
Sent: Thursday, August 24, 2006 2:12 PM
To: [hidden email]
Subject: [SPSSX-L] Problem with Include and Python

Listers,

I have some SPSS syntax called DisplayDictionary2(Python).sps that
sucessully generates a data dictionary using Python when I open the
syntax and do Run All.

However, when I try to INCLUDE the syntax in a master syntax file (using
the command
INCLUDE 'U:\SPSS\Python\DisplayDictionary2(Python).SPS'.).  I get the
following error message:


  17  BEGIN PROGRAM.
  19  import spss, spssaux, DisplayDict2
  20  print "Data Dictionary for:", spssaux.GetDatasetInfo()
  21  print "Number of Variables:", spss.GetVariableCount()
  22  DisplayDict2.dictionary(measlevel=False)
Data Dictionary for:
Traceback (most recent call last):
  File "<string>", line 1, in ?
NameError: name 'spssaux' is not defined
  22  END PROGRAM.
  23
  24
  25  * End of INSERT and INCLUDE nesting level 01.

>Error # 5712 in column 8.  Text: spss

>A valid IMPORT subcommand name is expected but not found.  Recognized
>subcommands are FILE, TYPE, KEEP, DROP, RENAME, and MAP.
>This command not executed.

Is it possible to INCLUDE this kind of syntax?

Pat
Reply | Threaded
Open this post in threaded view
|

Re: Problem with Include and Python

Oliver, Richard
In reply to this post by Cleland, Patricia (EDU)
The short answer is: Try using INSERT instead of INCLUDE. The longer answer, from the documentation, is:

Scope and Limitations
Programmatic variables created in a program block cannot be used outside of program blocks. However, you can generate SPSS macro variables within program blocks that can be used outside program blocks.

Program blocks cannot be nested within program blocks.

Program blocks cannot be contained within DEFINE-!ENDDEFINE macro definitions.

Program blocks can be contained in command syntax files run via the INSERT command, with the default SYNTAX=INTERACTIVE setting. (If, however, an INSERT command containing a program block is run from within a program block, that would create a nested program block, which is not allowed.)

Program blocks cannot be contained within command syntax files run via the INCLUDE command.



-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Cleland, Patricia (EDU)
Sent: Thursday, August 24, 2006 2:12 PM
To: [hidden email]
Subject: Problem with Include and Python

Listers,

I have some SPSS syntax called DisplayDictionary2(Python).sps that sucessully generates a data dictionary using Python when I open the syntax and do Run All.

However, when I try to INCLUDE the syntax in a master syntax file (using the command INCLUDE 'U:\SPSS\Python\DisplayDictionary2(Python).SPS'.).  I get the following error message:


  17  BEGIN PROGRAM.
  19  import spss, spssaux, DisplayDict2
  20  print "Data Dictionary for:", spssaux.GetDatasetInfo()
  21  print "Number of Variables:", spss.GetVariableCount()
  22  DisplayDict2.dictionary(measlevel=False)
Data Dictionary for:
Traceback (most recent call last):
  File "<string>", line 1, in ?
NameError: name 'spssaux' is not defined
  22  END PROGRAM.
  23
  24
  25  * End of INSERT and INCLUDE nesting level 01.

>Error # 5712 in column 8.  Text: spss

>A valid IMPORT subcommand name is expected but not found.  Recognized
>subcommands are FILE, TYPE, KEEP, DROP, RENAME, and MAP.
>This command not executed.

Is it possible to INCLUDE this kind of syntax?

Pat