CONCAT

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

CONCAT

Kreischer,Resha M

I am trying to merge two fields together. I am pretty sure I need to use the concat function, but I am not sure how to do it.

 

I have two fields

 

1. Hispanic (1character field)

2. Race (5 character field)

 

Example

 

Hispanic            Race

   Y                   10000

   N                  00300

   Y                   00040

 

 

I want the new field to look like this Y10000

                                                    N00300

                                                    Y00040

 

How do I do this?

 

Thanks,

 

 

 

 

Reply | Threaded
Open this post in threaded view
|

Re: CONCAT

Bruce Weaver
Administrator
Yes, you can use CONCAT for this.  One thing you need to know is that you have to declare a new string variable before adding values to it.  E.g.,

STRING HispRace (A6). /* Create a new A6 string variable called HispRace.

Then write the COMPUTE statement to assign the concatenation of HISPANIC and RACE to HispRace.  I'll leave it to you to try this.  If you're not sure how to write it directly, you can always do it via the Transform-Compute dialog in the GUI, and paste the syntax.  In the dialog, you'll find CONCAT in the String function group.

Good luck.


Kreischer,Resha M wrote
I am trying to merge two fields together. I am pretty sure I need to use
the concat function, but I am not sure how to do it.

 

I have two fields

 

1. Hispanic (1character field)

2. Race (5 character field)

 

Example

 

Hispanic            Race

   Y                   10000

   N                  00300

   Y                   00040

 

 

I want the new field to look like this Y10000

                                                    N00300

                                                    Y00040

 

How do I do this?

 

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: CONCAT

Tesiny, Ed
In reply to this post by Kreischer,Resha M

STRING newvar(6).

compute newvar=CONCAT (Hispanic, Race).

 

Ed Tesiny

[hidden email]

From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Kreischer,Resha M
Sent: Wednesday, November 03, 2010 4:10 PM
To: [hidden email]
Subject: CONCAT

 

I am trying to merge two fields together. I am pretty sure I need to use the concat function, but I am not sure how to do it.

 

I have two fields

 

1. Hispanic (1character field)

2. Race (5 character field)

 

Example

 

Hispanic            Race

   Y                   10000

   N                  00300

   Y                   00040

 

 

I want the new field to look like this Y10000

                                                    N00300

                                                    Y00040

 

How do I do this?

 

Thanks,