Automatic fill syntax

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

Automatic fill syntax

Jennifer Jones
Hello all,



I would like to make SPSS automatically fill in some information for me but
I do not know how to write the syntax. If I can figure out how to do one
then it will be a simple matter of plugging different variables into the
equation. What I want to tell SPSS to do is this:



If variable TOPIC does not equal 'colorectal cancer' (this is a string) than
automatically plug in 'not present' (or code number 0) for variable
SOC_NORM.



Is there a way to tell the program to do this? I could save hours if this
type of syntax can be written.





Jennifer Jones

=====================
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: Automatic fill syntax

Daniel Robertson
Hi Jennifer,

Assuming SOC_NORM is a numeric variable, this should work:

IF (TOPIC NE 'colorectal cancer') SOC_NORM = 0.

Dan R.

JenniferJones wrote:

> Hello all,
>
>
>
> I would like to make SPSS automatically fill in some information for me but
> I do not know how to write the syntax. If I can figure out how to do one
> then it will be a simple matter of plugging different variables into the
> equation. What I want to tell SPSS to do is this:
>
>
>
> If variable TOPIC does not equal 'colorectal cancer' (this is a string) than
> automatically plug in 'not present' (or code number 0) for variable
> SOC_NORM.
>
>
>
> Is there a way to tell the program to do this? I could save hours if this
> type of syntax can be written.
>
>
>

--
Daniel Robertson
Senior Research and Planning Associate
Institutional Research and Planning
Cornell University, Ithaca NY 14853-2801
607.255.9642 / irp.cornell.edu

=====================
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: Automatic fill syntax

Graham Wright-2
In reply to this post by Jennifer Jones
If I understand what you want correctly this is very simple.

first you have to declare SOC_NORM if it doesn't already exist, and
declare its max length
I picked 255 but you could choose some other number as long as its
longer than the longest string that appears in the variable.

string SOC_NORM(a255).

If SOC_NORM already exists then all you have to do is this:

if (TOPIC <>"colorectal cancer") SOC_NORM="not present".
execute.


-Graham

JenniferJones wrote:

> Hello all,
>
>
>
> I would like to make SPSS automatically fill in some information for me but
> I do not know how to write the syntax. If I can figure out how to do one
> then it will be a simple matter of plugging different variables into the
> equation. What I want to tell SPSS to do is this:
>
>
>
> If variable TOPIC does not equal 'colorectal cancer' (this is a string) than
> automatically plug in 'not present' (or code number 0) for variable
> SOC_NORM.
>
>
>
> Is there a way to tell the program to do this? I could save hours if this
> type of syntax can be written.
>
>
>
>
>
> Jennifer Jones
>
> =====================
> 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: Automatic fill syntax

Jennifer Jones
In reply to this post by Jennifer Jones
Mr. Wright,

The response I am receiving is as follows:

>Error # 1.  Command name: SOC_NORM0
>The first word in the line is not recognized as an SPSS command.
>This command not executed.

Also, I do not need think I need to add the value as it already exists as do
both of the variables.

What is happening is that all cases are now showing 'not present' including
those for TOPIC variable 'Colorectal cancer.'

What I would like to happen is that any case that where TOPIC does equal
'Colorectal cancer' will remain blank.

Any suggestions?

Jennifer

-----Original Message-----
From: Graham Wright [mailto:[hidden email]]
Sent: Tuesday, November 27, 2007 3:15 PM
To: ViAnn Beadle
Cc: 'JenniferJones'
Subject: Re: Automatic fill syntax

you're right, it's probably easier in general to have it as a numeric,
in which case it's even easier to make

if (TOPIC <>"colorectal cancer") SOC_NORM=0.

* then if you want *

add value labels

SOC_NORM0="not present"
.

-G


ViAnn Beadle wrote:
> So why do you assume that the OP wants SOC_NORM as a string? It sounds to
me

> like Jennifer might want this as a numeric variable with a value label of
> 'not present'.
>
> -----Original Message-----
> From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of
> Graham Wright
> Sent: Tuesday, November 27, 2007 12:56 PM
> To: [hidden email]
> Subject: Re: Automatic fill syntax
>
> If I understand what you want correctly this is very simple.
>
> first you have to declare SOC_NORM if it doesn't already exist, and
> declare its max length
> I picked 255 but you could choose some other number as long as its
> longer than the longest string that appears in the variable.
>
> string SOC_NORM(a255).
>
> If SOC_NORM already exists then all you have to do is this:
>
> if (TOPIC <>"colorectal cancer") SOC_NORM="not present".
> execute.
>
>
> -Graham
>
> JenniferJones wrote:
>
>> Hello all,
>>
>>
>>
>> I would like to make SPSS automatically fill in some information for me
>>
> but
>
>> I do not know how to write the syntax. If I can figure out how to do one
>> then it will be a simple matter of plugging different variables into the
>> equation. What I want to tell SPSS to do is this:
>>
>>
>>
>> If variable TOPIC does not equal 'colorectal cancer' (this is a string)
>>
> than
>
>> automatically plug in 'not present' (or code number 0) for variable
>> SOC_NORM.
>>
>>
>>
>> Is there a way to tell the program to do this? I could save hours if this
>> type of syntax can be written.
>>
>>
>>
>>
>>
>> Jennifer Jones
>>
>> =====================
>> 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
>

=====================
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: Automatic fill syntax

Marks, Jim
Jennifer:

Your error looks like the result of a command typed over two lines:

IF topic <> 'Colorectal cancer'

SOC_NORM0

vs

IF topic <> 'Colorectal cancer'
    SOC_NORM = 0


In the first case, SPSS will interpret the blank like as the end of a
command. The line starting SOC_NORM is read as a new command, and errors
out-- there is no spss command called SOC_NORM.

For your data, do you have this situation (possibly due to a previous
command affecting SOC_NORM):

TOPIC                           SOC_NORM
Colorectal cancer       not present
Parkinsons                      not present

and want to have this situation:

TOPIC                           SOC_NORM
Colorectal cancer       0
Parkinsons                      not present

If so, this should work:

IF topic = 'Colorectal cancer' soc_norm = '0'.


Notice that the exact string matters when evaluating string variables.
The follow examples of TOPIC

Colorectal Cancer
Colorectal  cancer
colorectal cancer

all will be unaffected by the IF command above-- they have misplaced
upper/ lower case characters or an extra blank.

Since you have a variable with the wrong information, you also might try
starting fresh:

COMPUTE no_CRcancer = TOPIC <> 'Colorectal cancer'.

This will give you a numeric variable called no_CRcancer with a 1 for
all cases where topic does not equal the exact string 'Colorectal
cancer' and a 0 for all cases where topic does equal the exact string.

--jim


-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of
JenniferJones
Sent: Tuesday, November 27, 2007 2:20 PM
To: [hidden email]
Subject: Re: Automatic fill syntax

Mr. Wright,

The response I am receiving is as follows:

>Error # 1.  Command name: SOC_NORM0
>The first word in the line is not recognized as an SPSS command.
>This command not executed.

Also, I do not need think I need to add the value as it already exists
as do both of the variables.

What is happening is that all cases are now showing 'not present'
including those for TOPIC variable 'Colorectal cancer.'

What I would like to happen is that any case that where TOPIC does equal
'Colorectal cancer' will remain blank.

Any suggestions?

Jennifer

-----Original Message-----
From: Graham Wright [mailto:[hidden email]]
Sent: Tuesday, November 27, 2007 3:15 PM
To: ViAnn Beadle
Cc: 'JenniferJones'
Subject: Re: Automatic fill syntax

you're right, it's probably easier in general to have it as a numeric,
in which case it's even easier to make

if (TOPIC <>"colorectal cancer") SOC_NORM=0.

* then if you want *

add value labels

SOC_NORM0="not present"
.

-G


ViAnn Beadle wrote:
> So why do you assume that the OP wants SOC_NORM as a string? It sounds

> to
me
> like Jennifer might want this as a numeric variable with a value label

> of 'not present'.
>
> -----Original Message-----
> From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf
> Of Graham Wright
> Sent: Tuesday, November 27, 2007 12:56 PM
> To: [hidden email]
> Subject: Re: Automatic fill syntax
>
> If I understand what you want correctly this is very simple.
>
> first you have to declare SOC_NORM if it doesn't already exist, and
> declare its max length I picked 255 but you could choose some other
> number as long as its longer than the longest string that appears in
> the variable.
>
> string SOC_NORM(a255).
>
> If SOC_NORM already exists then all you have to do is this:
>
> if (TOPIC <>"colorectal cancer") SOC_NORM="not present".
> execute.
>
>
> -Graham
>
> JenniferJones wrote:
>
>> Hello all,
>>
>>
>>
>> I would like to make SPSS automatically fill in some information for
>> me
>>
> but
>
>> I do not know how to write the syntax. If I can figure out how to do
>> one then it will be a simple matter of plugging different variables
>> into the equation. What I want to tell SPSS to do is this:
>>
>>
>>
>> If variable TOPIC does not equal 'colorectal cancer' (this is a
>> string)
>>
> than
>
>> automatically plug in 'not present' (or code number 0) for variable
>> SOC_NORM.
>>
>>
>>
>> Is there a way to tell the program to do this? I could save hours if
>> this type of syntax can be written.
>>
>>
>>
>>
>>
>> Jennifer Jones
>>
>> =====================
>> 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
>

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