LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous messageNext messagePrevious in topicNext in topicPrevious by same authorNext by same authorPrevious page (October 2009)Back to main SPSSX-L pageJoin or leave SPSSX-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Thu, 8 Oct 2009 13:19:00 -0600
Reply-To:     ViAnn Beadle <vab88011@gmail.com>
Sender:       "SPSSX(r) Discussion" <SPSSX-L@LISTSERV.UGA.EDU>
From:         ViAnn Beadle <vab88011@gmail.com>
Subject:      Re: Simple (I think) problem with a Macro
Comments: To: David Futrell <dfutrell62@yahoo.com>
In-Reply-To:  <17225.75988.qm@web53911.mail.re2.yahoo.com>
Content-Type: multipart/alternative;

You cannot directly transfer a data value to a macro in this way. You are getting this error because G4max in the macro is just a string value. Macros are really, really limited (e.g., dumb). In the past clever SPSSers would do things like generate macros on the fly by using the WRITE command to create a syntax file with some interspersed data values. Now, the best way to do this is to use Python to generate the syntax and run it because Python knows about the contents of the dictionary (variable names and such) and can retrieve case values.

From: SPSSX(r) Discussion [mailto:SPSSX-L@LISTSERV.UGA.EDU] On Behalf Of David Futrell Sent: Thursday, October 08, 2009 8:25 AM To: SPSSX-L@LISTSERV.UGA.EDU Subject: Simple (I think) problem with a Macro

Hi everyone:

I have an annoying problem with a macro that I hope someone can help me solve. The following syntax works perfectly.

DEFINE !REPORTMACRO().

!DO !I=1 !TO 865 temporary. select if any(!I,g4id1 to g4id9). compute report_owner=!I. save outfile=!QUOTE(!CONCAT("D:\Monthly Pulse Survey\G4 Reports\ID ",!I,".sav.")) /keep report_owner empid. !DOEND

!ENDDEFINE

!REPORTMACRO.

However, I want to use a calculated value in the !DO line instead of the constant (in this case 865) because this value varies across reporting periods and I currently have to calculate it and manually enter the value into the macro.

I can easily calculate what the end value should be using the aggregate command. Here's what I've tried to do:

compute max_x=max(g4id1 to g4id10). AGGREGATE /OUTFILE=* MODE=ADDVARIABLES /BREAK= /G4max=MAX(max_x).

DEFINE !REPORTMACRO().

!DO !I=1 !TO G4max temporary. select if any(!I,g4id1 to g4id9). compute report_owner=!I. save outfile=!QUOTE(!CONCAT("D:\Monthly Pulse Survey\G4 Reports\ID ",!I,".sav.")) /keep report_owner empid. !DOEND

!ENDDEFINE

!REPORTMACRO.

The calculated value (G4max) is exactly 865, but when I try the syntax, I get this message:

>Warning # 228 >Invalid string found where numeric value required in macro expression.

>Warning # 221 >Macro expansion found an error interpreting an operation code. Check the >arguments to functions and loop parameters for valid values.

>Error # 1. Command name: !ERROR_MACRO >The first word in the line is not recognized as an SPSS Statistics command.

>This command not executed.

Any ideas?

David Futrell Eli Lilly and Company


[text/html]


Back to: Top of message | Previous page | Main SPSSX-L page