|Date: ||Fri, 6 Jun 2003 14:31:29 -0500|
|Reply-To: ||"Marks, Jim" <Jim.Marks@lodgenet.com>|
|Sender: ||"SPSSX(r) Discussion" <SPSSX-L@LISTSERV.UGA.EDU>|
|From: ||"Marks, Jim" <Jim.Marks@lodgenet.com>|
|Subject: ||Re: Syntax shortcut help|
|Content-Type: ||text/plain; charset="iso-8859-1"|
VECTOR plus LOOP will do it:
** sample data.
DATA LIST LIST /place month.
LOOP #i = 1 to 4.
COMPUTE plamon(#i) = 0.
IF month = (#i) plamon(#i) = place.
VECTOR will create the variables (playmon1 to playmon4) and process each one through the LOOP in this example. The first number in the VECTOR command indicates the number of new variables to be created; the LOOP command should match.
Make sure that the "root" variable names for your other variables don't have more than 6 characters-- otherwise you get illegal names with two digit numbers.
Senior Market Analyst
LodgeNet Entertainment Corporation
From: Rosenthal, James A [mailto:firstname.lastname@example.org]
Sent: Friday, June 06, 2003 1:53 PM
Subject: Syntax shortcut help
Dear SPSSX user:
Am interested to know whether SPPS has any syntax "short-cut" that could be
applied in the following or similar situation. Suppose I have two
PLACE = type of placement (1 = foster home 2 = group home 3 = etc)
MONTH = month of placement 1= first month, 2 = second, 3 = third, etc)
Suppose that placement can occur in any of four months. My goal is to
create four new variables -- PLAMON1, PLAMON2, PLAMON3, PLAMON4 - that will
take on the value of PLACE if the placement occurs in the appropriate month.
So, suppose I have this data:
the following new variables with the following values need to be created for
for the first case, PLAMON3 with the value 2
for the second case, PLAMON4 with the value 1
for the third case, PLAMON2 with the value 2
for the fourth case, PLAMON1 with the value 3
for the fifth case, PLAMON4 with the value 2
The following code will implement the above:
if MONTH = 1 PLAMON1 = PLACE.
if MONTH = 2 PLAMON2 = PLACE.
if MONTH = 3 PLAMON3 = PLACE.
if MONTH = 4 PLAMON4 = PLACE.
Is there some short-cut way to implement this code, perhaps with "do loop -
end loop" or something like this? In the example here, there are only
fourth months but in reality I have about 40 months and need to implement
similar logic for about 10 variables. So, if there is a short-cut that
would be great.
Many thanks for looking at this and for any help you may be able to provide.
James A. Rosenthal, Ph.D.
University of Oklahoma
School of Social Work
1005 Jenkins Ave.
Norman, OK 73019