merge two numeric variables (NOT add)

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

merge two numeric variables (NOT add)

leonleo
This post was updated on .
hi,
i'm trying to merge two numeric variables to create a unique ID. These variables are month and year (example below). So both of them are numeric. I want them to join (or concatenate) to create a new variable preferably a new numeric one. I know the concatenate command works for string variables. But its not working for these numeric variables.

How can i get same output for two numeric variables?
Any help would be much appreciated.

E.g.
Month        Year     UID (This is what I need to achieve)
1            2010     12010
2            2011     22011

thanks
Reply | Threaded
Open this post in threaded view
|

Re: merge two numeric variables (NOT add)

Bruce Weaver
Administrator

COMPUTE UID = Month*10**4 + Year.
FORMATS UID (F6.0).


leonleo wrote
hi,
i'm trying to merge two numeric variables to create a unique ID. These variables are month and year (example below). So both of them are numeric. I want them to join (or concatenate) to create a new variable preferably a new numeric one. I know the concatenate command works for string variables. But its not working for these numeric variables.

How can i get same output for two numeric variables?
Any help would be much appreciated.

E.g.
Month        Year     UID (This is what I need to achieve)
1            2010     12010
2            2011     22011

thanks
--
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: merge two numeric variables (NOT add)

leonleo
In reply to this post by leonleo
Bruce thanks - it worked. what do you mean by this FORMATS UID (F6.0)
 


Reply | Threaded
Open this post in threaded view
|

Re: merge two numeric variables (NOT add)

David Marso
Administrator
FM?
leonleo wrote
Bruce thanks - it worked. what do you mean by this FORMATS UID (F6.0)
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?"
Reply | Threaded
Open this post in threaded view
|

Re: merge two numeric variables (NOT add)

Bruce Weaver
Administrator
Translation:  Look up the FORMATS command in the "fine manual" (aka the Command Syntax Reference manual).  


David Marso wrote
FM?
leonleo wrote
Bruce thanks - it worked. what do you mean by this FORMATS UID (F6.0)
--
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/).