What's wrong with this macro?

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

What's wrong with this macro?

Luca Meyer-3
Hello,

I am writing a macro to repeat a number of times the following operation:

TEMPORARY.
SELECT IF INDEX(QUESTION,"[D00184]")>0 AND RESPONSE="1".
SAVE OUTFILE "T/2010SLAM_D00184_1.SAV" /KEEP RESPONSEID ROWTEXT.

The variable bits of the syntax I am trying to built are question id (D00184) and response id (1).

Can anyone suggest what's wrong with this macro?

SET PRINTBACK LISTING.
SET MPRINT ON.

DEFINE !IMPORT (D=!TOKENS(1) /R=!TOKENS(1))
!DO !I=1 !TO !R.
!TEMPORARY.
!IF (!INDEX(QUESTION,!QUOTE(!CONCAT('[',!D,']'))>0 !AND RESPONSE=!QUOTE(!I)) !THEN
SAVE OUTFILE=!QUOTE(!CONCAT('T/2010SLAM_',!D,'_',!I,'.SAV')) /KEEP RESPONSEID ROWTEXT.
!IFEND
!DOEND.
!ENDDEFINE.

!IMPORT !D=D00184 !R=3.

The output I get is:

SET PRINTBACK LISTING.
5943  0 M>  SET PRINTBACK LISTING.
SET MPRINT ON.
5944  0 M>  SET MPRINT ON.

5945  0 M>  
DEFINE !IMPORT (D=!TOKENS(1) /R=!TOKENS(1))
5946  0 M>  DEFINE
5947  0 M>   !IMPORT (D=!TOKENS(1) /R=!TOKENS(1))
!DO !I=1 !TO !R.
5948  0 M>  !DO !I=1 !TO !R.
!TEMPORARY.
5949  0 M>  !TEMPORARY.
!IF (!INDEX(QUESTION,!QUOTE(!CONCAT('[',!D,']'))>0 !AND RESPONSE=!QUOTE(!I)) !THEN.
5950  0 M>  !IF (!INDEX(QUESTION,!QUOTE(!CONCAT('[',!D,']'))>0 !AND RESPONSE=!QUOTE(!I)) !THEN.

>Error # 6844 in column 78.  Text: !THEN
>The end of a macro expression occurred when an operator was expected.
>Execution of this command stops.
SAVE OUTFILE=!QUOTE(!CONCAT('T/2010SLAM_',!D,'_',!I,'.SAV')) /KEEP RESPONSEID ROWTEXT.
5951  0 M>  SAVE OUTFILE=!QUOTE(!CONCAT('T/2010SLAM_',!D,'_',!I,'.SAV')) /KEEP RESPONSEID ROWTEXT.
!IFEND.
5952  0 M>  !IFEND.
!DOEND.
5953  0 M>  !DOEND.
!ENDDEFINE.
5954  0 M>  !ENDDEFINE.


Or, in alternative, is there a easier/more efficient way to do what I am trying to do with Python programmability?

Thanks,
Luca

Luca Meyer
www.lucameyer.com
PASW Statistics v. 18.0.2 (2-apr-2010)
R version 2.9.2 (2009-08-24)
Mac OS X 10.6.3 (10D573) - kernel Darwin 10.3.0

Reply | Threaded
Open this post in threaded view
|

Re: What's wrong with this macro?

Marks, Jim

Is the error the !AND command? Try changing !AND to AND:

 

!IF (!INDEX(QUESTION,!QUOTE(!CONCAT('[',!D,']'))>0 !AND RESPONSE=!QUOTE(!I)) !THEN

 

to

 

!IF (!INDEX(QUESTION,!QUOTE(!CONCAT('[',!D,']'))>0 AND RESPONSE=!QUOTE(!I)) !THEN

 

 

 

Jim Marks

Director, Market Research

x1616

 

From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Luca Meyer
Sent: Wednesday, June 09, 2010 2:45 PM
To: [hidden email]
Subject: What's wrong with this macro?

 

Hello,

 

I am writing a macro to repeat a number of times the following operation:

 

TEMPORARY.

SELECT IF INDEX(QUESTION,"[D00184]")>0 AND RESPONSE="1".

SAVE OUTFILE "T/2010SLAM_D00184_1.SAV" /KEEP RESPONSEID ROWTEXT.

 

The variable bits of the syntax I am trying to built are question id (D00184) and response id (1).

 

Can anyone suggest what's wrong with this macro?

 

SET PRINTBACK LISTING.

SET MPRINT ON.

 

DEFINE !IMPORT (D=!TOKENS(1) /R=!TOKENS(1))

!DO !I=1 !TO !R.

!TEMPORARY.

!IF (!INDEX(QUESTION,!QUOTE(!CONCAT('[',!D,']'))>0 !AND RESPONSE=!QUOTE(!I)) !THEN

SAVE OUTFILE=!QUOTE(!CONCAT('T/2010SLAM_',!D,'_',!I,'.SAV')) /KEEP RESPONSEID ROWTEXT.

!IFEND

!DOEND.

!ENDDEFINE.

 

!IMPORT !D=D00184 !R=3.

 

The output I get is:

 

SET PRINTBACK LISTING.
5943  0 M>  SET PRINTBACK LISTING.
SET MPRINT ON.
5944  0 M>  SET MPRINT ON.

5945  0 M>  
DEFINE !IMPORT (D=!TOKENS(1) /R=!TOKENS(1))
5946  0 M>  DEFINE
5947  0 M>   !IMPORT (D=!TOKENS(1) /R=!TOKENS(1))
!DO !I=1 !TO !R.
5948  0 M>  !DO !I=1 !TO !R.
!TEMPORARY.
5949  0 M>  !TEMPORARY.
!IF (!INDEX(QUESTION,!QUOTE(!CONCAT('[',!D,']'))>0 !AND RESPONSE=!QUOTE(!I)) !THEN.
5950  0 M>  !IF (!INDEX(QUESTION,!QUOTE(!CONCAT('[',!D,']'))>0 !AND RESPONSE=!QUOTE(!I)) !THEN.

>Error # 6844 in column 78.  Text: !THEN
>The end of a macro expression occurred when an operator was expected.
>Execution of this command stops.
SAVE OUTFILE=!QUOTE(!CONCAT('T/2010SLAM_',!D,'_',!I,'.SAV')) /KEEP RESPONSEID ROWTEXT.
5951  0 M>  SAVE OUTFILE=!QUOTE(!CONCAT('T/2010SLAM_',!D,'_',!I,'.SAV')) /KEEP RESPONSEID ROWTEXT.
!IFEND.
5952  0 M>  !IFEND.
!DOEND.
5953  0 M>  !DOEND.
!ENDDEFINE.
5954  0 M>  !ENDDEFINE.

Or, in alternative, is there a easier/more efficient way to do what I am trying to do with Python programmability?

 

Thanks,

Luca

 

Luca Meyer
www.lucameyer.com
PASW Statistics v. 18.0.2 (2-apr-2010)

R version 2.9.2 (2009-08-24)
Mac OS X 10.6.3 (10D573) - kernel Darwin 10.3.0

 

Reply | Threaded
Open this post in threaded view
|

Re: What's wrong with this macro?

Bruce Weaver
Administrator
In reply to this post by Luca Meyer-3
I think that one problem is you are treating ordinary syntax commands as if they are macro commands.  E.g., why do you have !TEMPORARY rather than just TEMPORARY?

In the straight syntax, you use a TEMPORARY-SELECT-IF.  Why do you change from that in the macro?  I.e., why not try something like this?


DEFINE !IMPORT (D=!TOKENS(1) /R=!TOKENS(1))
!DO !I=1 !TO !R.
TEMPORARY.
SELECT IF INDEX(QUESTION,!QUOTE(!CONCAT('[',!D,']') ) )>0 AND RESPONSE=!QUOTE(!I).
SAVE OUTFILE=!QUOTE(!CONCAT('T/2010SLAM_',!D,'_',!I,'.SAV')) /KEEP RESPONSEID ROWTEXT.
!DOEND.
!ENDDEFINE.


This is untested, of course.


Luca Meyer-3 wrote
Hello,

I am writing a macro to repeat a number of times the following operation:

TEMPORARY.
SELECT IF INDEX(QUESTION,"[D00184]")>0 AND RESPONSE="1".
SAVE OUTFILE "T/2010SLAM_D00184_1.SAV" /KEEP RESPONSEID ROWTEXT.

The variable bits of the syntax I am trying to built are question id (D00184) and response id (1).

Can anyone suggest what's wrong with this macro?

SET PRINTBACK LISTING.
SET MPRINT ON.

DEFINE !IMPORT (D=!TOKENS(1) /R=!TOKENS(1))
!DO !I=1 !TO !R.
!TEMPORARY.
!IF (!INDEX(QUESTION,!QUOTE(!CONCAT('[',!D,']'))>0 !AND RESPONSE=!QUOTE(!I)) !THEN
SAVE OUTFILE=!QUOTE(!CONCAT('T/2010SLAM_',!D,'_',!I,'.SAV')) /KEEP RESPONSEID ROWTEXT.
!IFEND
!DOEND.
!ENDDEFINE.

!IMPORT !D=D00184 !R=3.

The output I get is:

SET PRINTBACK LISTING.
5943  0 M>  SET PRINTBACK LISTING.
SET MPRINT ON.
5944  0 M>  SET MPRINT ON.

5945  0 M>  
DEFINE !IMPORT (D=!TOKENS(1) /R=!TOKENS(1))
5946  0 M>  DEFINE
5947  0 M>   !IMPORT (D=!TOKENS(1) /R=!TOKENS(1))
!DO !I=1 !TO !R.
5948  0 M>  !DO !I=1 !TO !R.
!TEMPORARY.
5949  0 M>  !TEMPORARY.
!IF (!INDEX(QUESTION,!QUOTE(!CONCAT('[',!D,']'))>0 !AND RESPONSE=!QUOTE(!I)) !THEN.
5950  0 M>  !IF (!INDEX(QUESTION,!QUOTE(!CONCAT('[',!D,']'))>0 !AND RESPONSE=!QUOTE(!I)) !THEN.

>Error # 6844 in column 78.  Text: !THEN
>The end of a macro expression occurred when an operator was expected.
>Execution of this command stops.
SAVE OUTFILE=!QUOTE(!CONCAT('T/2010SLAM_',!D,'_',!I,'.SAV')) /KEEP RESPONSEID ROWTEXT.
5951  0 M>  SAVE OUTFILE=!QUOTE(!CONCAT('T/2010SLAM_',!D,'_',!I,'.SAV')) /KEEP RESPONSEID ROWTEXT.
!IFEND.
5952  0 M>  !IFEND.
!DOEND.
5953  0 M>  !DOEND.
!ENDDEFINE.
5954  0 M>  !ENDDEFINE.

Or, in alternative, is there a easier/more efficient way to do what I am trying to do with Python programmability?

Thanks,
Luca

Luca Meyer
www.lucameyer.com
PASW Statistics v. 18.0.2 (2-apr-2010)
R version 2.9.2 (2009-08-24)
Mac OS X 10.6.3 (10D573) - kernel Darwin 10.3.0
--
Bruce Weaver
bweaver@lakeheadu.ca
http://sites.google.com/a/lakeheadu.ca/bweaver/

"When all else fails, RTFM."

PLEASE NOTE THE FOLLOWING: 
1. My Hotmail account is not monitored regularly. To send me an e-mail, please use the address shown above.
2. The SPSSX Discussion forum on Nabble is no longer linked to the SPSSX-L listserv administered by UGA (https://listserv.uga.edu/).
Reply | Threaded
Open this post in threaded view
|

Re: What's wrong with this macro?

Luca Meyer-3
Hello Bruce,

The format you propose does not yield error but when I run 

!IMPORT !D=D00184 !R=3.

I get:

>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.
7455  0 M>  !ERROR_MACRO

>Error # 1.  Command name: !ERROR_MACRO
>The first word in the line is not recognized as a PASW Statistics command.
>Execution of this command stops.
7456  0 M>   !D=D00184 !R=3.


And I do not get the 3 files I expected.

Do you have any idea why this is happening?

Cheers,
Luca


Il giorno 09/giu/2010, alle ore 22.46, Bruce Weaver ha scritto:

I think that one problem is you are treating ordinary syntax commands as if
they are macro commands.  E.g., why do you have !TEMPORARY rather than just
TEMPORARY?

In the straight syntax, you use a TEMPORARY-SELECT-IF.  Why do you change
from that in the macro?  I.e., why not try something like this?


DEFINE !IMPORT (D=!TOKENS(1) /R=!TOKENS(1))
!DO !I=1 !TO !R.
TEMPORARY.
SELECT IF INDEX(QUESTION,!QUOTE(!CONCAT('[',!D,']') ) )>0 AND
RESPONSE=!QUOTE(!I).
SAVE OUTFILE=!QUOTE(!CONCAT('T/2010SLAM_',!D,'_',!I,'.SAV')) /KEEP
RESPONSEID ROWTEXT.
!DOEND.
!ENDDEFINE.


This is untested, of course.



Luca Meyer-3 wrote:

Hello,

I am writing a macro to repeat a number of times the following operation:

TEMPORARY.
SELECT IF INDEX(QUESTION,"[D00184]")>0 AND RESPONSE="1".
SAVE OUTFILE "T/2010SLAM_D00184_1.SAV" /KEEP RESPONSEID ROWTEXT.

The variable bits of the syntax I am trying to built are question id
(D00184) and response id (1).

Can anyone suggest what's wrong with this macro?

SET PRINTBACK LISTING.
SET MPRINT ON.

DEFINE !IMPORT (D=!TOKENS(1) /R=!TOKENS(1))
!DO !I=1 !TO !R.
!TEMPORARY.
!IF (!INDEX(QUESTION,!QUOTE(!CONCAT('[',!D,']'))>0 !AND
RESPONSE=!QUOTE(!I)) !THEN
SAVE OUTFILE=!QUOTE(!CONCAT('T/2010SLAM_',!D,'_',!I,'.SAV')) /KEEP
RESPONSEID ROWTEXT.
!IFEND
!DOEND.
!ENDDEFINE.

!IMPORT !D=D00184 !R=3.

The output I get is:

SET PRINTBACK LISTING.
5943  0 M>  SET PRINTBACK LISTING.
SET MPRINT ON.
5944  0 M>  SET MPRINT ON.

5945  0 M>
DEFINE !IMPORT (D=!TOKENS(1) /R=!TOKENS(1))
5946  0 M>  DEFINE
5947  0 M>   !IMPORT (D=!TOKENS(1) /R=!TOKENS(1))
!DO !I=1 !TO !R.
5948  0 M>  !DO !I=1 !TO !R.
!TEMPORARY.
5949  0 M>  !TEMPORARY.
!IF (!INDEX(QUESTION,!QUOTE(!CONCAT('[',!D,']'))>0 !AND
RESPONSE=!QUOTE(!I)) !THEN.
5950  0 M>  !IF (!INDEX(QUESTION,!QUOTE(!CONCAT('[',!D,']'))>0 !AND
RESPONSE=!QUOTE(!I)) !THEN.

Error # 6844 in column 78.  Text: !THEN
The end of a macro expression occurred when an operator was expected.
Execution of this command stops.
SAVE OUTFILE=!QUOTE(!CONCAT('T/2010SLAM_',!D,'_',!I,'.SAV')) /KEEP
RESPONSEID ROWTEXT.
5951  0 M>  SAVE OUTFILE=!QUOTE(!CONCAT('T/2010SLAM_',!D,'_',!I,'.SAV'))
/KEEP RESPONSEID ROWTEXT.
!IFEND.
5952  0 M>  !IFEND.
!DOEND.
5953  0 M>  !DOEND.
!ENDDEFINE.
5954  0 M>  !ENDDEFINE.

Or, in alternative, is there a easier/more efficient way to do what I am
trying to do with Python programmability?

Thanks,
Luca

Luca Meyer
www.lucameyer.com
PASW Statistics v. 18.0.2 (2-apr-2010)
R version 2.9.2 (2009-08-24)
Mac OS X 10.6.3 (10D573) - kernel Darwin 10.3.0





-----
--
Bruce Weaver
[hidden email]
http://sites.google.com/a/lakeheadu.ca/bweaver/
"When all else fails, RTFM."

NOTE:  My Hotmail account is not monitored regularly.
To send me an e-mail, please use the address shown above.
--
View this message in context: http://old.nabble.com/What%27s-wrong-with-this-macro--tp28835013p28835614.html
Sent from the SPSSX Discussion mailing list archive at Nabble.com.

=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (not to SPSSX-L), with no body text except the
command. To leave the list, send the command
SIGNOFF SPSSX-L
For a list of commands to manage subscriptions, send the command
INFO REFCARD

Reply | Threaded
Open this post in threaded view
|

Re: What's wrong with this macro?

Csernai, Eszter

Hi Luca,

 

I think in the macro call, you should not use the “!” in front of the argument names.

 

That is, the macro call should be: !IMPORT D=D00184 R=3.

 

I am not sure this is what causes the problem, but maybe it is worth a try.

 

Eszter

 

 

 

From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Luca Meyer
Sent: 10 June 2010 00:19
To: [hidden email]
Subject: Re: What's wrong with this macro?

 

Hello Bruce,

 

The format you propose does not yield error but when I run 

 

!IMPORT !D=D00184 !R=3.

 

I get:

 

>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.
7455  0 M>  !ERROR_MACRO

>Error # 1.  Command name: !ERROR_MACRO
>The first word in the line is not recognized as a PASW Statistics command.
>Execution of this command stops.
7456  0 M>   !D=D00184 !R=3.

And I do not get the 3 files I expected.

 

Do you have any idea why this is happening?

 

Cheers,

Luca

 

 

Il giorno 09/giu/2010, alle ore 22.46, Bruce Weaver ha scritto:



I think that one problem is you are treating ordinary syntax commands as if
they are macro commands.  E.g., why do you have !TEMPORARY rather than just
TEMPORARY?

In the straight syntax, you use a TEMPORARY-SELECT-IF.  Why do you change
from that in the macro?  I.e., why not try something like this?


DEFINE !IMPORT (D=!TOKENS(1) /R=!TOKENS(1))
!DO !I=1 !TO !R.
TEMPORARY.
SELECT IF INDEX(QUESTION,!QUOTE(!CONCAT('[',!D,']') ) )>0 AND
RESPONSE=!QUOTE(!I).
SAVE OUTFILE=!QUOTE(!CONCAT('T/2010SLAM_',!D,'_',!I,'.SAV')) /KEEP
RESPONSEID ROWTEXT.
!DOEND.
!ENDDEFINE.


This is untested, of course.



Luca Meyer-3 wrote:

 

Hello,

 

I am writing a macro to repeat a number of times the following operation:

 

TEMPORARY.

SELECT IF INDEX(QUESTION,"[D00184]")>0 AND RESPONSE="1".

SAVE OUTFILE "T/2010SLAM_D00184_1.SAV" /KEEP RESPONSEID ROWTEXT.

 

The variable bits of the syntax I am trying to built are question id

(D00184) and response id (1).

 

Can anyone suggest what's wrong with this macro?

 

SET PRINTBACK LISTING.

SET MPRINT ON.

 

DEFINE !IMPORT (D=!TOKENS(1) /R=!TOKENS(1))

!DO !I=1 !TO !R.

!TEMPORARY.

!IF (!INDEX(QUESTION,!QUOTE(!CONCAT('[',!D,']'))>0 !AND

RESPONSE=!QUOTE(!I)) !THEN

SAVE OUTFILE=!QUOTE(!CONCAT('T/2010SLAM_',!D,'_',!I,'.SAV')) /KEEP

RESPONSEID ROWTEXT.

!IFEND

!DOEND.

!ENDDEFINE.

 

!IMPORT !D=D00184 !R=3.

 

The output I get is:

 

SET PRINTBACK LISTING.

5943  0 M>  SET PRINTBACK LISTING.

SET MPRINT ON.

5944  0 M>  SET MPRINT ON.

 

5945  0 M>

DEFINE !IMPORT (D=!TOKENS(1) /R=!TOKENS(1))

5946  0 M>  DEFINE

5947  0 M>   !IMPORT (D=!TOKENS(1) /R=!TOKENS(1))

!DO !I=1 !TO !R.

5948  0 M>  !DO !I=1 !TO !R.

!TEMPORARY.

5949  0 M>  !TEMPORARY.

!IF (!INDEX(QUESTION,!QUOTE(!CONCAT('[',!D,']'))>0 !AND

RESPONSE=!QUOTE(!I)) !THEN.

5950  0 M>  !IF (!INDEX(QUESTION,!QUOTE(!CONCAT('[',!D,']'))>0 !AND

RESPONSE=!QUOTE(!I)) !THEN.

 

Error # 6844 in column 78.  Text: !THEN

The end of a macro expression occurred when an operator was expected.

Execution of this command stops.

SAVE OUTFILE=!QUOTE(!CONCAT('T/2010SLAM_',!D,'_',!I,'.SAV')) /KEEP

RESPONSEID ROWTEXT.

5951  0 M>  SAVE OUTFILE=!QUOTE(!CONCAT('T/2010SLAM_',!D,'_',!I,'.SAV'))

/KEEP RESPONSEID ROWTEXT.

!IFEND.

5952  0 M>  !IFEND.

!DOEND.

5953  0 M>  !DOEND.

!ENDDEFINE.

5954  0 M>  !ENDDEFINE.

 

Or, in alternative, is there a easier/more efficient way to do what I am

trying to do with Python programmability?

 

Thanks,

Luca

 

Luca Meyer

www.lucameyer.com

PASW Statistics v. 18.0.2 (2-apr-2010)

R version 2.9.2 (2009-08-24)

Mac OS X 10.6.3 (10D573) - kernel Darwin 10.3.0

 

 

 



-----
--
Bruce Weaver
[hidden email]
http://sites.google.com/a/lakeheadu.ca/bweaver/
"When all else fails, RTFM."

NOTE:  My Hotmail account is not monitored regularly.
To send me an e-mail, please use the address shown above.
--
View this message in context: http://old.nabble.com/What%27s-wrong-with-this-macro--tp28835013p28835614.html
Sent from the SPSSX Discussion mailing list archive at Nabble.com.

=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (not to SPSSX-L), with no body text except the
command. To leave the list, send the command
SIGNOFF SPSSX-L
For a list of commands to manage subscriptions, send the command
INFO REFCARD

 



IMPORTANT NOTICE: This e-mail message and all attachments, if any, may contain confidential and privileged material and are intended only for the person or entity to which the message is addressed. If you are not an intended recipient, you are hereby notified that any use, dissemination, distribution, disclosure, or copying of this information is unauthorized and strictly prohibited. If you have received this communication in error, please contact the sender immediately by reply e-mail, and destroy all copies of the original message.
Reply | Threaded
Open this post in threaded view
|

Re: What's wrong with this macro?

Luca Meyer-3
<base href="x-msg://69/">Thanks Eszter,

That was it, not it works!

Luca

Il giorno 10/giu/2010, alle ore 13.50, Csernai, Eszter ha scritto:

Hi Luca,
 
I think in the macro call, you should not use the “!” in front of the argument names.
 
That is, the macro call should be: !IMPORT D=D00184 R=3.
 
I am not sure this is what causes the problem, but maybe it is worth a try.
 
Eszter
 
 
 
From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Luca Meyer
Sent: 10 June 2010 00:19
To: [hidden email]
Subject: Re: What's wrong with this macro?
 
Hello Bruce,
 
The format you propose does not yield error but when I run 
 
!IMPORT !D=D00184 !R=3.
 
I get:
 

>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.
7455  0 M>  !ERROR_MACRO

>Error # 1.  Command name: !ERROR_MACRO
>The first word in the line is not recognized as a PASW Statistics command.
>Execution of this command stops.
7456  0 M>   !D=D00184 !R=3.

And I do not get the 3 files I expected.
 
Do you have any idea why this is happening?
 
Cheers,
Luca
 
 
Il giorno 09/giu/2010, alle ore 22.46, Bruce Weaver ha scritto:


I think that one problem is you are treating ordinary syntax commands as if
they are macro commands.  E.g., why do you have !TEMPORARY rather than just
TEMPORARY?

In the straight syntax, you use a TEMPORARY-SELECT-IF.  Why do you change
from that in the macro?  I.e., why not try something like this?


DEFINE !IMPORT (D=!TOKENS(1) /R=!TOKENS(1))
!DO !I=1 !TO !R.
TEMPORARY.
SELECT IF INDEX(QUESTION,!QUOTE(!CONCAT('[',!D,']') ) )>0 AND
RESPONSE=!QUOTE(!I).
SAVE OUTFILE=!QUOTE(!CONCAT('T/2010SLAM_',!D,'_',!I,'.SAV')) /KEEP
RESPONSEID ROWTEXT.
!DOEND.
!ENDDEFINE.


This is untested, of course.



Luca Meyer-3 wrote:

 
Hello,
 
I am writing a macro to repeat a number of times the following operation:
 
TEMPORARY.
SELECT IF INDEX(QUESTION,"[D00184]")>0 AND RESPONSE="1".
SAVE OUTFILE "T/2010SLAM_D00184_1.SAV" /KEEP RESPONSEID ROWTEXT.
 
The variable bits of the syntax I am trying to built are question id
(D00184) and response id (1).
 
Can anyone suggest what's wrong with this macro?
 
SET PRINTBACK LISTING.
SET MPRINT ON.
 
DEFINE !IMPORT (D=!TOKENS(1) /R=!TOKENS(1))
!DO !I=1 !TO !R.
!TEMPORARY.
!IF (!INDEX(QUESTION,!QUOTE(!CONCAT('[',!D,']'))>0 !AND
RESPONSE=!QUOTE(!I)) !THEN
SAVE OUTFILE=!QUOTE(!CONCAT('T/2010SLAM_',!D,'_',!I,'.SAV')) /KEEP
RESPONSEID ROWTEXT.
!IFEND
!DOEND.
!ENDDEFINE.
 
!IMPORT !D=D00184 !R=3.
 
The output I get is:
 
SET PRINTBACK LISTING.
5943  0 M>  SET PRINTBACK LISTING.
SET MPRINT ON.
5944  0 M>  SET MPRINT ON.
 
5945  0 M>
DEFINE !IMPORT (D=!TOKENS(1) /R=!TOKENS(1))
5946  0 M>  DEFINE
5947  0 M>   !IMPORT (D=!TOKENS(1) /R=!TOKENS(1))
!DO !I=1 !TO !R.
5948  0 M>  !DO !I=1 !TO !R.
!TEMPORARY.
5949  0 M>  !TEMPORARY.
!IF (!INDEX(QUESTION,!QUOTE(!CONCAT('[',!D,']'))>0 !AND
RESPONSE=!QUOTE(!I)) !THEN.
5950  0 M>  !IF (!INDEX(QUESTION,!QUOTE(!CONCAT('[',!D,']'))>0 !AND
RESPONSE=!QUOTE(!I)) !THEN.
 
Error # 6844 in column 78.  Text: !THEN
The end of a macro expression occurred when an operator was expected.
Execution of this command stops.
SAVE OUTFILE=!QUOTE(!CONCAT('T/2010SLAM_',!D,'_',!I,'.SAV')) /KEEP
RESPONSEID ROWTEXT.
5951  0 M>  SAVE OUTFILE=!QUOTE(!CONCAT('T/2010SLAM_',!D,'_',!I,'.SAV'))
/KEEP RESPONSEID ROWTEXT.
!IFEND.
5952  0 M>  !IFEND.
!DOEND.
5953  0 M>  !DOEND.
!ENDDEFINE.
5954  0 M>  !ENDDEFINE.
 
Or, in alternative, is there a easier/more efficient way to do what I am
trying to do with Python programmability?
 
Thanks,
Luca
 
Luca Meyer
PASW Statistics v. 18.0.2 (2-apr-2010)
R version 2.9.2 (2009-08-24)
Mac OS X 10.6.3 (10D573) - kernel Darwin 10.3.0
 
 
 


-----
--
Bruce Weaver
[hidden email]
http://sites.google.com/a/lakeheadu.ca/bweaver/
"When all else fails, RTFM."

NOTE:  My Hotmail account is not monitored regularly.
To send me an e-mail, please use the address shown above.
--
View this message in context: http://old.nabble.com/What%27s-wrong-with-this-macro--tp28835013p28835614.html
Sent from the SPSSX Discussion mailing list archive at Nabble.com.

=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (not to SPSSX-L), with no body text except the
command. To leave the list, send the command
SIGNOFF SPSSX-L
For a list of commands to manage subscriptions, send the command
INFO REFCARD
 


IMPORTANT NOTICE: This e-mail message and all attachments, if any, may contain confidential and privileged material and are intended only for the person or entity to which the message is addressed. If you are not an intended recipient, you are hereby notified that any use, dissemination, distribution, disclosure, or copying of this information is unauthorized and strictly prohibited. If you have received this communication in error, please contact the sender immediately by reply e-mail, and destroy all copies of the original message.