Date: Mon, 1 Feb 1999 12:06:06 -0600
Reply-To: "Bauer, John" <bauer@SPSS.COM>
Sender: "SPSSX(r) Discussion" <SPSSX-L@UGA.CC.UGA.EDU>
From: "Bauer, John" <bauer@SPSS.COM>
Subject: Re: Syntax macros & SPSSscripts
Scripts have two methods for running SPSS syntax commands: .ExecuteCommands
and .ExecuteInclude; both belong to the application object (objSpssApp).
For the moment, assume that your macro is stored in a file "Plot3
Macro.sps", and that the macro's arguments have been stored in an array.
Then the architecture of your script is very simple: use .ExecuteInclude to
initialize the macro, assemble the arguments into a single string, and
execute it with .ExecuteCommands:
vntPlotArg = Array (1, 27, "qu14s", 24, "equ14")
'call the subroutine which sets up the macro
'This subroutine handles everything associated with the Plot3 Macro.
'It Includes the macro, assembles the arguments into a single string,
'and calls the macro.
Dim i As Integer
Dim strCmd As String
'Include the macro.
objSpssApp.ExecuteInclude "Plot3 Macro.sps", True
'Build up a string of macro arguments.
For i = 0 To UBound(vntArg)
strCmd = strCmd & " arg" & Trim$(CStr(i)) & "=" & vntArg(i)
'Set up the macro call.
strCmd = "Plot3 " & strCmd & " ."
'Execute the macro.
objSpssApp.ExecuteCommands strCmd, True
I don't want to get into a discussion of the dialog editor here. There are
various examples of scripts using dialogs on the SPSS Script eXchange, which
has recently moved to a new url:
If you have SPSS 9, look on the CD-ROM in the directory "\SPSS Products and
Services\SPSS Script eXchange\Sax Basic Dialog Editor" for some scripts
which demo variable lists.
SPSS Developer Support
> -----Original Message-----
> From: Michael Zaengle [SMTP:zaengle.michael@MAIL.STATISTIK.BFZ.DE]
> Sent: Monday, February 01, 1999 5:12 AM
> To: SPSSX-L@UGA.CC.UGA.EDU
> Subject: Syntax macros & SPSSscripts
> Michael Zaengle
> define plot3 (arg1 = !tokens(1)
> /arg2 = !tokens(1)
> /arg3 = !tokens(1)
> /arg4 = !tokens(1)
> /arg5 = !tokens(1)).
> !DO !I = !arg1 !to !arg2.
> tsplot var = !Concat(!arg3,!I) !Concat(!arg3,!arg4) !arg5 /id = erfq.
> * call plot3:.
> plot3 arg1 = 1 arg2 = 27 arg3 = qu14s arg4 = 24 arg5 =equ14.
> Is it possible to assign values to the arguments of the SPSS-macro "plot"
> in an SPSS-script by UserDialog and DialogFunc.If so, does anybody know an
> appropriate starter that could help me to do the scripting job?
> The above macro call produces time series plots for insertion rates of a
> labour market programm in 27 bavarian regions, compared to region
> Nr.24(arg4) and Bavaria as a whole (arg5). The user dialog should enable
> the user to choose his region of analysis (arg4) that is to be compared
> with the rest of the 27 regions. In addition, the user should have the
> choice between different kinds of indicators (arg3).
> As far as I know, scripts don't accept SPSS-Syntax macro commands, so the
> idea would be to
> start with a Syntax window, inserting a user dialog script the output of
> which should be a Syntax
> macro call. Is this feasable?