Continuation on a Compute

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

Continuation on a Compute

Bob Schacht-3
I've been trying to save a sequence of actions for rapid use next year when
the same questions will arise.
In recovering syntax from the log, one of the statements comes out as

COMPUTE filter_$=(PDSOURCE= '08' OR PDSOURCE = '12' OR PDSOURCE = '21' OR
    PDSOURCE = '25' OR PDSOURCE = '34').

However, this must not have been two lines in the original, because in this
version, SPSSX (ver. 12) interprets the second line as a variable label
command, and replaced the label of the variable PDSOURCE with the string
"'25' OR PDSOURCE = '34')"

How do I properly indicate a continuation line for this COMPUTE command?

Thanks,
Bob Schacht

Robert M. Schacht, Ph.D. <[hidden email]>
Pacific Basin Rehabilitation Research & Training Center
1268 Young Street, Suite #204
Research Center, University of Hawaii
Honolulu, HI 96814

=====================
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: Continuation on a Compute

Oliver, Richard
It looks like a valid Compute statement to me. The continuation line is indented, and the command terminator is at the end of the second line, so it should work in either batch or interactive mode. I don't see how the second line could be interpreted as a Variable Label command even if it were interpreted as a new command rather than a continuation line.

________________________________

From: SPSSX(r) Discussion on behalf of Bob Schacht
Sent: Tue 10/30/2007 9:47 PM
To: [hidden email]
Subject: Continuation on a Compute



I've been trying to save a sequence of actions for rapid use next year when
the same questions will arise.
In recovering syntax from the log, one of the statements comes out as

COMPUTE filter_$=(PDSOURCE= '08' OR PDSOURCE = '12' OR PDSOURCE = '21' OR
    PDSOURCE = '25' OR PDSOURCE = '34').

However, this must not have been two lines in the original, because in this
version, SPSSX (ver. 12) interprets the second line as a variable label
command, and replaced the label of the variable PDSOURCE with the string
"'25' OR PDSOURCE = '34')"

How do I properly indicate a continuation line for this COMPUTE command?

Thanks,
Bob Schacht

Robert M. Schacht, Ph.D. <[hidden email]>
Pacific Basin Rehabilitation Research & Training Center
1268 Young Street, Suite #204
Research Center, University of Hawaii
Honolulu, HI 96814

=====================
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: Continuation on a Compute

Art Kendall-2
In reply to this post by Bob Schacht-3
I don't see a problem as the command stands. perhaps you can cut-paste
and post the few lines above the error message and the message itself.

a workaround would be something like
COMPUTE filter_$= any(PDSOURCE, '08' , '12' , '21' , '25', '34').

Art Kendall
Social Research Consultants


Bob Schacht wrote:

> I've been trying to save a sequence of actions for rapid use next year
> when
> the same questions will arise.
> In recovering syntax from the log, one of the statements comes out as
>
> COMPUTE filter_$=(PDSOURCE= '08' OR PDSOURCE = '12' OR PDSOURCE = '21' OR
>    PDSOURCE = '25' OR PDSOURCE = '34').
>
> However, this must not have been two lines in the original, because in
> this
> version, SPSSX (ver. 12) interprets the second line as a variable label
> command, and replaced the label of the variable PDSOURCE with the string
> "'25' OR PDSOURCE = '34')"
>
> How do I properly indicate a continuation line for this COMPUTE command?
>
> Thanks,
> Bob Schacht
>
> Robert M. Schacht, Ph.D. <[hidden email]>
> Pacific Basin Rehabilitation Research & Training Center
> 1268 Young Street, Suite #204
> Research Center, University of Hawaii
> Honolulu, HI 96814
>
> =====================
> 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: Continuation on a Compute

Bob Schacht-3
At 02:15 AM 10/31/2007, Art Kendall wrote:
>I don't see a problem as the command stands. perhaps you can cut-paste
>and post the few lines above the error message and the message itself.

Your suspicions seem well-founded. David Millar <[hidden email]> wrote
off-list,

>Just a thought Bob,
>Do you have a comment just above the piece of syntax you sent?  I have seen
>cases where something like
>
>*Creating filter
>COMPUTE filter_$=(PDSOURCE= '08' OR PDSOURCE = '12' OR PDSOURCE = '21' OR
>     PDSOURCE = '25' OR PDSOURCE = '34').
>
>means that the next line after the comment is not read.  This is usually
>cured by the inclusion of a period on the comment line - to become
>
>*Creating filter.
>
>Hope this is of some help.

Indeed, I did have a preceding comment that was not closed, and closing it
with a period seemed to solve the problem. Are there any acceptable closure
symbols other than a period? e.g., semi-colons, colons, dashes?


>a workaround would be something like
>COMPUTE filter_$= any(PDSOURCE, '08' , '12' , '21' , '25', '34').

Thank you for this suggestion. I didn't know about this syntax option.
Bob Schacht

=====================
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: Continuation on a Compute

ViAnn Beadle
There are two different sets of syntax rules:

INTERACTIVE mode requires that a command end in a period or is followed by a
completely empty line. When you execute syntax "interactively" by running it
from an open syntax window--it is always run in interactive mode.

BATCH mode does not require a command terminator but the command must always
start in column 1. Batch mode is always used when executing an external
syntax file referenced on the INCLUDE command or named on the command line
when running from a console window.

The INSERT command which functionally replaces the legacy INCLUDE allows you
to specify either mode when executing an external file.

BATCH mode requires that SPSS look ahead one line to determine the end of
command--it is looking for a non-blank character in column 1 and
recognizable command name. This is not very friendly in an interactive
environment since it basically would require you to execute a command ahead
to determine if the current command is correct. Hence the invention of the
command terminator for interactive mode when SPSS was ported to the PC in
1984.

When SPSS "pastes" syntax, it always adds a period at the end, and starts
new commands in column 1. Thus, this syntax will work in either interactive
or batch mode.

Note that other languages sometimes use a continuation character to indicate
that the command spans lines. This is not particularly friendly in an
interactive environment either--forget the continuation line and the command
executes prematurely.

But to answer your question, an alternative to the period as command
terminator is to insert a completely blank line between commands.

All the gory details are described in Help>Topics>Working with Command
Syntax>Syntax Rules.



-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Bob
Schacht
Sent: Wednesday, October 31, 2007 4:08 PM
To: [hidden email]
Subject: Re: Continuation on a Compute

At 02:15 AM 10/31/2007, Art Kendall wrote:
>I don't see a problem as the command stands. perhaps you can cut-paste
>and post the few lines above the error message and the message itself.

Your suspicions seem well-founded. David Millar <[hidden email]> wrote
off-list,

>Just a thought Bob,
>Do you have a comment just above the piece of syntax you sent?  I have seen
>cases where something like
>
>*Creating filter
>COMPUTE filter_$=(PDSOURCE= '08' OR PDSOURCE = '12' OR PDSOURCE = '21' OR
>     PDSOURCE = '25' OR PDSOURCE = '34').
>
>means that the next line after the comment is not read.  This is usually
>cured by the inclusion of a period on the comment line - to become
>
>*Creating filter.
>
>Hope this is of some help.

Indeed, I did have a preceding comment that was not closed, and closing it
with a period seemed to solve the problem. Are there any acceptable closure
symbols other than a period? e.g., semi-colons, colons, dashes?


>a workaround would be something like
>COMPUTE filter_$= any(PDSOURCE, '08' , '12' , '21' , '25', '34').

Thank you for this suggestion. I didn't know about this syntax option.
Bob Schacht

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

Compute syntax

Bob Schacht-3
While trying to construct a filter variable, I ran this syntax:

COMPUTE GOODJOBS = any(CLOEMPST, '1','3','4','7') AND HrlyWage>=7.25 AND
STAT =
    '26'.

and get this error:
 >Error # 4325 in column 49.  Text: )
 >The arguments to the ANY and RANGE functions must be either all strings (or
 >string expressions) or all numeric variables (or numeric expressions).
 >This command not executed.

I intended this as a logical statement, i.e., GoodJobs = 1 if the three
conditions are true, and 0 otherwise.
The ANY function can be used with COMPUTE, but here it seems that the
syntax editor is trying to extend the ANY function beyond the closing
parenthesis.

How can I fix this? What am I doing wrong?

I am using SPSS ver. 12

Bob

Robert M. Schacht, Ph.D. <[hidden email]>
Pacific Basin Rehabilitation Research & Training Center
1268 Young Street, Suite #204
Research Center, University of Hawaii
Honolulu, HI 96814

=====================
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: Compute syntax

ViAnn Beadle
Is CLOEMPST a string variable?

-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Bob
Schacht
Sent: Tuesday, November 06, 2007 7:49 PM
To: [hidden email]
Subject: Compute syntax

While trying to construct a filter variable, I ran this syntax:

COMPUTE GOODJOBS = any(CLOEMPST, '1','3','4','7') AND HrlyWage>=7.25 AND
STAT =
    '26'.

and get this error:
 >Error # 4325 in column 49.  Text: )
 >The arguments to the ANY and RANGE functions must be either all strings
(or
 >string expressions) or all numeric variables (or numeric expressions).
 >This command not executed.

I intended this as a logical statement, i.e., GoodJobs = 1 if the three
conditions are true, and 0 otherwise.
The ANY function can be used with COMPUTE, but here it seems that the
syntax editor is trying to extend the ANY function beyond the closing
parenthesis.

How can I fix this? What am I doing wrong?

I am using SPSS ver. 12

Bob

Robert M. Schacht, Ph.D. <[hidden email]>
Pacific Basin Rehabilitation Research & Training Center
1268 Young Street, Suite #204
Research Center, University of Hawaii
Honolulu, HI 96814

=====================
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: Compute syntax

Bob Schacht-3
At 05:17 PM 11/6/2007, ViAnn Beadle wrote:
>Is CLOEMPST a string variable?

Bingo. No, this time I had it set up as numeric.
Thanks for pointing me in the right direction.

Bob


>-----Original Message-----
>From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Bob
>Schacht
>Sent: Tuesday, November 06, 2007 7:49 PM
>To: [hidden email]
>Subject: Compute syntax
>
>While trying to construct a filter variable, I ran this syntax:
>
>COMPUTE GOODJOBS = any(CLOEMPST, '1','3','4','7') AND HrlyWage>=7.25 AND
>STAT =
>     '26'.
>
>and get this error:
>  >Error # 4325 in column 49.  Text: )
>  >The arguments to the ANY and RANGE functions must be either all strings
>(or
>  >string expressions) or all numeric variables (or numeric expressions).
>  >This command not executed.
>
>I intended this as a logical statement, i.e., GoodJobs = 1 if the three
>conditions are true, and 0 otherwise.
>The ANY function can be used with COMPUTE, but here it seems that the
>syntax editor is trying to extend the ANY function beyond the closing
>parenthesis.
>
>How can I fix this? What am I doing wrong?
>
>I am using SPSS ver. 12
>
>Bob
>
>Robert M. Schacht, Ph.D. <[hidden email]>
>Pacific Basin Rehabilitation Research & Training Center
>1268 Young Street, Suite #204
>Research Center, University of Hawaii
>Honolulu, HI 96814
>
>=====================
>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

Robert M. Schacht, Ph.D. <[hidden email]>
Pacific Basin Rehabilitation Research & Training Center
1268 Young Street, Suite #204
Research Center, University of Hawaii
Honolulu, HI 96814

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