STRING command doesn't seem to create variable

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

STRING command doesn't seem to create variable

Mike Pritchard-4
I'm trying to create a variable using the STRING command.  SPSS shows that it completes without error, but the variable doesn't show up and a subsequent COMPUTE command fails.

* Source variable for UK
STRING SourceVar (A10).
EXECUTE.
COMPUTE SourceVar = "UK".
EXECUTE.

Can anyone see what's wrong?

I'm using V16.

Thanks
Mike
Reply | Threaded
Open this post in threaded view
|

Re: STRING command doesn't seem to create variable

King Douglas

SPSS is reading the word STRING as a continuation of the comment.  So put a period or a blank line after the comment in first line.  Ending with a period is better.  I like to do both.  It’s not necessary to have two Execute commands.

 

* Source variable for UK.

STRING SourceVar (A10).

COMPUTE SourceVar = "UK".
EXECUTE.

 

King Douglas

 

 

From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Mike Pritchard
Sent: Saturday, February 06, 2010 2:00 PM
To: [hidden email]
Subject: STRING command doesn't seem to create variable

 

I'm trying to create a variable using the STRING command.  SPSS shows that it completes without error, but the variable doesn't show up and a subsequent COMPUTE command fails.

* Source variable for UK
STRING SourceVar (A10).
EXECUTE.
COMPUTE SourceVar = "UK".
EXECUTE.

Can anyone see what's wrong?

I'm using V16.

Thanks
Mike

Reply | Threaded
Open this post in threaded view
|

Re: STRING command doesn't seem to create variable

Mike Pritchard
Thanks.  I struggle with SPSS comments, especially since I'm doing some programming in a different language with other comment syntax.
Mike

On Sat, Feb 6, 2010 at 12:47 PM, King Douglas <[hidden email]> wrote:

SPSS is reading the word STRING as a continuation of the comment.  So put a period or a blank line after the comment in first line.  Ending with a period is better.  I like to do both.  It’s not necessary to have two Execute commands.

 

* Source variable for UK.

STRING SourceVar (A10).

COMPUTE SourceVar = "UK".
EXECUTE.

 

King Douglas

 

 

From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Mike Pritchard
Sent: Saturday, February 06, 2010 2:00 PM
To: [hidden email]
Subject: STRING command doesn't seem to create variable

 

I'm trying to create a variable using the STRING command.  SPSS shows that it completes without error, but the variable doesn't show up and a subsequent COMPUTE command fails.

* Source variable for UK
STRING SourceVar (A10).
EXECUTE.
COMPUTE SourceVar = "UK".
EXECUTE.

Can anyone see what's wrong?

I'm using V16.

Thanks
Mike


Reply | Threaded
Open this post in threaded view
|

Re: STRING command doesn't seem to create variable

Jon K Peck

If you are using the syntax editor in V17 or later, you should notice that comments appear in a different color, helping you to spot omitted periods.

Jon Peck
SPSS, an IBM Company
[hidden email]
312-651-3435



From: Mike Pritchard <[hidden email]>
To: [hidden email]
Date: 02/06/2010 07:23 PM
Subject: Re: [SPSSX-L] STRING command doesn't seem to create variable
Sent by: "SPSSX(r) Discussion" <[hidden email]>





Thanks.  I struggle with SPSS comments, especially since I'm doing some programming in a different language with other comment syntax.
Mike

On Sat, Feb 6, 2010 at 12:47 PM, King Douglas <king_d@...> wrote:
SPSS is reading the word STRING as a continuation of the comment.  So put a period or a blank line after the comment in first line.  Ending with a period is better.  I like to do both.  It’s not necessary to have two Execute commands.

 

* Source variable for UK.

STRING SourceVar (A10).

COMPUTE SourceVar = "UK".
EXECUTE.

 

King Douglas

 

 

From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Mike Pritchard
Sent:
Saturday, February 06, 2010 2:00 PM
To:
[hidden email]
Subject:
STRING command doesn't seem to create variable

 

I'm trying to create a variable using the STRING command.  SPSS shows that it completes without error, but the variable doesn't show up and a subsequent COMPUTE command fails.

* Source variable for UK
STRING SourceVar (A10).
EXECUTE.
COMPUTE SourceVar = "UK".
EXECUTE.

Can anyone see what's wrong?

I'm using V16.

Thanks
Mike

Reply | Threaded
Open this post in threaded view
|

Re: STRING command doesn't seem to create variable

Ruben Geert van den Berg
In reply to this post by Mike Pritchard-4
"SPSS shows that it completes without error, but the variable doesn't show up and a subsequent COMPUTE command fails."

Problem solved but nonetheless you should get an error message as well, providing you with at least a clue about what's going wrong (in V15 at least):

>Error # 4309 in column 256.  Text: (End of Command)
>Invalid combination of data types in an assignment.  Character strings may
>only be assigned to string variables.  Numeric and logical quantities may
>only be assigned to numeric variables.  Consider using the STRING or NUMBER
>function.
>This command not executed.

Best regards,

Ruben van den Berg

Methodologist

TNS NIPO

E: [hidden email]

P: +31 20 522 5738

I: www.tns-nipo.com



data list free/bla.
begin data
0
end data.

*oops
STRING SourceVar (A10).
EXECUTE.
COMPUTE SourceVar = "UK".
EXECUTE.


Date: Sat, 6 Feb 2010 12:00:07 -0800
From: [hidden email]
Subject: STRING command doesn't seem to create variable
To: [hidden email]

I'm trying to create a variable using the STRING command.  SPSS shows that it completes without error, but the variable doesn't show up and a subsequent COMPUTE command fails.

* Source variable for UK
STRING SourceVar (A10).
EXECUTE.
COMPUTE SourceVar = "UK".
EXECUTE.

Can anyone see what's wrong?

I'm using V16.

Thanks
Mike


New Windows 7: Find the right PC for you. Learn more.
Reply | Threaded
Open this post in threaded view
|

Re: STRING command doesn't seem to create variable

Mike Pritchard

Ruben,

You are right.  Thanks for the correction.  I didn’t give complete enough information.  When I ran the first couple of lines, there was no error- because as someone else pointed out the comment was only concluded by the period at the end of the STRING command.  But when I ran all the lines, or just the last couple, the error message was displayed.  Same thing with V16 as V15.

 

Mike


From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Ruben van den Berg
Sent: Sunday, February 07, 2010 2:06 AM
To: [hidden email]
Subject: Re: STRING command doesn't seem to create variable

 

"SPSS shows that it completes without error, but the variable doesn't show up and a subsequent COMPUTE command fails."

 

Problem solved but nonetheless you should get an error message as well, providing you with at least a clue about what's going wrong (in V15 at least):

 

>Error # 4309 in column 256.  Text: (End of Command)

>Invalid combination of data types in an assignment.  Character strings may

>only be assigned to string variables.  Numeric and logical quantities may

>only be assigned to numeric variables.  Consider using the STRING or NUMBER

>function.

>This command not executed.

 

Best regards,

 

Ruben van den Berg

Methodologist

TNS NIPO

E: [hidden email]

P: +31 20 522 5738

I: www.tns-nipo.com

 

data list free/bla.

begin data

0

end data.

 

*oops

STRING SourceVar (A10).

EXECUTE.

COMPUTE SourceVar = "UK".

EXECUTE.

 


Date: Sat, 6 Feb 2010 12:00:07 -0800
From: [hidden email]
Subject: STRING command doesn't seem to create variable
To: [hidden email]

I'm trying to create a variable using the STRING command.  SPSS shows that it completes without error, but the variable doesn't show up and a subsequent COMPUTE command fails.

* Source variable for UK
STRING SourceVar (A10).
EXECUTE.
COMPUTE SourceVar = "UK".
EXECUTE.

Can anyone see what's wrong?

I'm using V16.

Thanks
Mike

 


New Windows 7: Find the right PC for you. Learn more.