altering a variable in SPSS

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

altering a variable in SPSS

stace swayne
Dear Listserv,

I have two questions regarding data manipulation

The first question is: Is it possible to concatenate variables in SPSS: for example I have a household ID and a person ID and I would like to combine them together.

The second question is: Is it possible to sort on two variables simultaneously: for example sorting on household ID and person ID at the same time.


All suggestions are welcomed.


Reply | Threaded
Open this post in threaded view
|

Re: altering a variable in SPSS

Rick Oliver-3
yes and yes

Assuming IDs are strings:

string newID (a50). /*or whatever length is necessary.
compute newID=concat(rtrim(idvar1), (idvar2)).
sort cases by var1 var2.

Rick Oliver
Senior Information Developer
IBM Business Analytics (SPSS)
E-mail: [hidden email]




From:        stace swayne <[hidden email]>
To:        [hidden email],
Date:        10/15/2013 01:38 PM
Subject:        altering a variable in SPSS
Sent by:        "SPSSX(r) Discussion" <[hidden email]>




Dear Listserv,

I have two questions regarding data manipulation

The first question is: Is it possible to concatenate variables in SPSS: for example I have a household ID and a person ID and I would like to combine them together.

The second question is: Is it possible to sort on two variables simultaneously: for example sorting on household ID and person ID at the same time.


All suggestions are welcomed.


Reply | Threaded
Open this post in threaded view
|

Re: altering a variable in SPSS

David Marso
Administrator
If they are numeric then multiply the first by a power of 10 and add them.

Rick Oliver wrote
yes and yes

Assuming IDs are strings:

string newID (a50). /*or whatever length is necessary.
compute newID=concat(rtrim(idvar1), (idvar2)).
sort cases by var1 var2.

Rick Oliver
Senior Information Developer
IBM Business Analytics (SPSS)
E-mail: [hidden email]



From:   stace swayne <[hidden email]>
To:     [hidden email],
Date:   10/15/2013 01:38 PM
Subject:        altering a variable in SPSS
Sent by:        "SPSSX(r) Discussion" <[hidden email]>



Dear Listserv,

I have two questions regarding data manipulation

The first question is: Is it possible to concatenate variables in SPSS:
for example I have a household ID and a person ID and I would like to
combine them together.

The second question is: Is it possible to sort on two variables
simultaneously: for example sorting on household ID and person ID at the
same time.


All suggestions are welcomed.
Please reply to the list and not to my personal email.
Those desiring my consulting or training services please feel free to email me.
---
"Nolite dare sanctum canibus neque mittatis margaritas vestras ante porcos ne forte conculcent eas pedibus suis."
Cum es damnatorum possederunt porcos iens ut salire off sanguinum cliff in abyssum?"