Merging two variables

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

Merging two variables

Johnny Amora
Two variables in my SPSS file are YEAR1 and YEAR2.
YEAR1 refers to start of school year, while YEAR2
refers to end of school year.  Suppose I have 5 cases,
the two columns in my datafile would look like as
follows:

YEAR1   YEAR2
2003    2004
2003    2004
2004    2005
2005    2006
2006    2007

I want to create a variable called SCHOOLYEAR such
that the values are 2003-2004, 2004-2005;
2005-2006;2006-2007.  In this case my datafile would
look like:

YEAR1   YEAR2  SCHOLLYEAR
2003    2004   2003-2004
2003    2004   2003-2004
2004    2005   2004-2005
2005    2006   2005-2006
2006    2007   2006-2007

How to do this using syntax?

Thank you.
John




      ____________________________________________________________________________________
Looking for last minute shopping deals?
Find them fast with Yahoo! Search.  http://tools.search.yahoo.com/newsearch/category.php?category=shopping

=====================
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: Merging two variables

Albert-Jan Roskam
Hi John,

string schoolyear (a9).
compute schoolyear =
concat(string(year1,f4),'-',string(year2,f4)).

I didn't test this, but I think the code is correct.

Cheers!!
Albert-Jan


--- John Amora <[hidden email]> wrote:

> Two variables in my SPSS file are YEAR1 and YEAR2.
> YEAR1 refers to start of school year, while YEAR2
> refers to end of school year.  Suppose I have 5
> cases,
> the two columns in my datafile would look like as
> follows:
>
> YEAR1   YEAR2
> 2003    2004
> 2003    2004
> 2004    2005
> 2005    2006
> 2006    2007
>
> I want to create a variable called SCHOOLYEAR such
> that the values are 2003-2004, 2004-2005;
> 2005-2006;2006-2007.  In this case my datafile would
> look like:
>
> YEAR1   YEAR2  SCHOLLYEAR
> 2003    2004   2003-2004
> 2003    2004   2003-2004
> 2004    2005   2004-2005
> 2005    2006   2005-2006
> 2006    2007   2006-2007
>
> How to do this using syntax?
>
> Thank you.
> John
>
>
>
>
>
>
____________________________________________________________________________________
> Looking for last minute shopping deals?
> Find them fast with Yahoo! Search.
>
http://tools.search.yahoo.com/newsearch/category.php?category=shopping

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



      ____________________________________________________________________________________
Looking for last minute shopping deals?
Find them fast with Yahoo! Search.  http://tools.search.yahoo.com/newsearch/category.php?category=shopping

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