!LET not recognized

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

!LET not recognized

beny

I am trying to define local variables in my syntax to avoid my current method of global search and replace.
When I try to run this code in the syntax editor...
!LET !rawscore=m0005.

I am told "The first word in the line is not recognized as an SPSS Statistics command."
Reply | Threaded
Open this post in threaded view
|

Re: !LET not recognized

David Marso
Administrator
!LET is only applicable within the body of a MACRO (see DEFINE !ENDDEFINE).
I'm not sure exactly what you mean by the following
"define local variables in my syntax to avoid my current method of global search and replace"
BUT??

DEFINE !myvars ()
a b c d
!ENDDEFINE

FREQ !myvars .

OTOH:  I don't look favorably upon that approach.  Much better to set the bulk syntax up as a macro and pass parameters .
OTOH: Somebody is probably going to try to steer you away from macros and corrupt your mind with Python.


beny wrote
I am trying to define local variables in my syntax to avoid my current method of global search and replace.
When I try to run this code in the syntax editor...
!LET !rawscore=m0005.

I am told "The first word in the line is not recognized as an SPSS Statistics command."
Please reply to the list and not to my personal email.
Those desiring my consulting or training services please feel free to email me.
---
"Nolite dare sanctum canibus neque mittatis margaritas vestras ante porcos ne forte conculcent eas pedibus suis."
Cum es damnatorum possederunt porcos iens ut salire off sanguinum cliff in abyssum?"
Reply | Threaded
Open this post in threaded view
|

Re: !LET not recognized

Poes, Matthew Joseph
In reply to this post by beny
That's because it's a macro only command.  You need to define this as a macro first.

Matthew J Poes
Research Data Specialist
Center for Prevention Research and Development
University of Illinois
510 Devonshire Dr.
Champaign, IL 61820
Phone: 217-265-4576
email: [hidden email]


-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of beny
Sent: Wednesday, October 10, 2012 9:03 AM
To: [hidden email]
Subject: !LET not recognized

I am trying to define local variables in my syntax to avoid my current method of global search and replace.
When I try to run this code in the syntax editor...
!LET !rawscore=m0005.

I am told "The first word in the line is not recognized as an SPSS Statistics command."



--
View this message in context: http://spssx-discussion.1045642.n5.nabble.com/LET-not-recognized-tp5715575.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

=====================
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: !LET not recognized

Richard Ristow
In reply to this post by beny
At 10:02 AM 10/10/2012, beny wrote:

>I am trying to define local variables in my syntax to avoid my current
>method of global search and replace. When I try to run this code in
>the syntax editor...
>
>!LET !rawscore=m0005.
>
>I am told "The first word in the line is not recognized as an SPSS
>Statistics command."

Right. As others have told you, SPSS macro variables exist only
within macros, so this won't work. (This is confusing if you come
from SAS. SAS maintains a name space of macro variables even outside
macros, so this trick DOES work in SAS.)

However, though you can't define a macro variable with this value,
you can define a macro:


DEFINE !rawscore()m0005 !ENDDEFINE.

*  Macro /* !MacEcho */ is used to display the macro expansion   .
DEFINE !MacEcho(!POS !NOEXPAND !CMDEND)
    ECHO  !QUOTE(!CONCAT('     Call  : ',!1)).
    ECHO  !QUOTE(!CONCAT('     Result: ',!EVAL(!1))).
!ENDDEFINE.


!MacEcho !rawscore.
      Call  : !rawscore
      Result: m0005

=====================
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