In List Type Command

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

In List Type Command

cherylscott02
Is there a way to write syntax without having to continually reference the name of the target variable?  For example, suppose I am creating a new variable (NONDEG) based on certain values of the variable ACADPLAN.  This is the only way I know how to write something like this:
 
If  (acadplan = 'UND-DEG' or acadplan = 'JU-JU' or acadplan = 'ND-PI) Nondeg = 1.
 
In other languages there is an "in list" command.  Using the example above, the code in SPSS might look something like this:
 
if (in list(acadplan('UND-DEG', 'JU-JU', 'ND-PI')))Nondeg = 1.
 
Is there something like this in SPSS?  Thanks for your time.
 


--
Cheryl Scott
Assistant Director
Office of Institutional Research, Analysis and Effectiveness
Truckee Meadows Community College
(775)673-8239 (w)
 
CONFIDENTIALITY NOTICE: The information transmitted is intended only for the person or entity to which it is addressed and may contain confidential and/or privileged material. Any review, retransmission, dissemination or other use of, or taking of any action in reliance upon, this information by person or entities other than the intended recipient is prohibited. If you receive this in error, please contact the sender and delete the material from any computer.
Reply | Threaded
Open this post in threaded view
|

Re: In List Type Command

Jon K Peck
Look up the "any" function.
compute Nondeg = any(acadplan, "UND-DEG", "JU-JU", "ND-PI").


Jon Peck (no "h") aka Kim
Senior Software Engineer, IBM
[hidden email]
phone: 720-342-5621




From:        Cheryl Scott <[hidden email]>
To:        [hidden email],
Date:        09/24/2013 05:55 PM
Subject:        [SPSSX-L] In List Type Command
Sent by:        "SPSSX(r) Discussion" <[hidden email]>




Is there a way to write syntax without having to continually reference the name of the target variable?  For example, suppose I am creating a new variable (NONDEG) based on certain values of the variable ACADPLAN.  This is the only way I know how to write something like this:
 
If  (acadplan = 'UND-DEG' or acadplan = 'JU-JU' or acadplan = 'ND-PI) Nondeg = 1.
 
In other languages there is an "in list" command.  Using the example above, the code in SPSS might look something like this:
 
if (in list(acadplan('UND-DEG', 'JU-JU', 'ND-PI')))Nondeg = 1.
 
Is there something like this in SPSS?  Thanks for your time.
 


--

Cheryl Scott
Assistant Director
Office of Institutional Research, Analysis and Effectiveness
Truckee Meadows Community College
clscott@...
(775)673-8239 (w)
 
CONFIDENTIALITY NOTICE: The information transmitted is intended only for the person or entity to which it is addressed and may contain confidential and/or privileged material. Any review, retransmission, dissemination or other use of, or taking of any action in reliance upon, this information by person or entities other than the intended recipient is prohibited. If you receive this in error, please contact the sender and delete the material from any computer.
Reply | Threaded
Open this post in threaded view
|

Re: In List Type Command

Bruce Weaver
Administrator
And notice that ANY can be used in two different ways.

1. COMPUTE AnyOfSeveralValuesInOneVar = ANY(VarName,value1,value2,value3, ...,valueN).

2. COMPUTE GivenValueInAnyOfSeveralVars = ANY(value,Var1,Var2,Var3, ...,VarN).

When you are dealing with string variables, values must be enclosed in quotes.

HTH.


Jon K Peck wrote
Look up the "any" function.
compute Nondeg = any(acadplan, "UND-DEG", "JU-JU", "ND-PI").


Jon Peck (no "h") aka Kim
Senior Software Engineer, IBM
[hidden email]
phone: 720-342-5621




From:   Cheryl Scott <[hidden email]>
To:     [hidden email],
Date:   09/24/2013 05:55 PM
Subject:        [SPSSX-L] In List Type Command
Sent by:        "SPSSX(r) Discussion" <[hidden email]>



Is there a way to write syntax without having to continually reference the
name of the target variable?  For example, suppose I am creating a new
variable (NONDEG) based on certain values of the variable ACADPLAN.  This
is the only way I know how to write something like this:

If  (acadplan = 'UND-DEG' or acadplan = 'JU-JU' or acadplan = 'ND-PI)
Nondeg = 1.

In other languages there is an "in list" command.  Using the example
above, the code in SPSS might look something like this:

if (in list(acadplan('UND-DEG', 'JU-JU', 'ND-PI')))Nondeg = 1.

Is there something like this in SPSS?  Thanks for your time.



--
Cheryl Scott
Assistant Director
Office of Institutional Research, Analysis and Effectiveness
Truckee Meadows Community College
[hidden email]
(775)673-8239 (w)

CONFIDENTIALITY NOTICE: The information transmitted is intended only for
the person or entity to which it is addressed and may contain confidential
and/or privileged material. Any review, retransmission, dissemination or
other use of, or taking of any action in reliance upon, this information
by person or entities other than the intended recipient is prohibited. If
you receive this in error, please contact the sender and delete the
material from any computer.
--
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: In List Type Command

Ruben Geert van den Berg
You can find some more examples here (http://www.pythonforspss.org/any/) as well.