<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	>
<channel>
	<title>Comments on: Combine two variables into one</title>
	<atom:link href="http://www.spsslog.com/2007/04/10/combine-two-variables-into-one/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.spsslog.com/2007/04/10/combine-two-variables-into-one/</link>
	<description>From users, for users</description>
	<pubDate>Thu, 21 Aug 2008 17:19:41 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.6</generator>
		<item>
		<title>By: Alejandro</title>
		<link>http://www.spsslog.com/2007/04/10/combine-two-variables-into-one/#comment-7875</link>
		<dc:creator>Alejandro</dc:creator>
		<pubDate>Thu, 31 Jul 2008 22:58:07 +0000</pubDate>
		<guid isPermaLink="false">http://www.spsslog.com/2007/04/10/combine-two-variables-into-one/#comment-7875</guid>
		<description>HeY Smash. your sintaxis works perfect. 

thanks.</description>
		<content:encoded><![CDATA[<p>HeY Smash. your sintaxis works perfect. </p>
<p>thanks.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Smash</title>
		<link>http://www.spsslog.com/2007/04/10/combine-two-variables-into-one/#comment-3483</link>
		<dc:creator>Smash</dc:creator>
		<pubDate>Sun, 26 Aug 2007 15:08:31 +0000</pubDate>
		<guid isPermaLink="false">http://www.spsslog.com/2007/04/10/combine-two-variables-into-one/#comment-3483</guid>
		<description>For Wayne question (comment 3):

compute C=$sysmis.
if (A=0 &#38; B=0) C=0.
if (A=1 &#124; B=1) C=1.
exec.

For Thomas question (comment 5):
If there are sting variables, use the CONCAT function (to join variables) and RTRIM function (to remove blanks).

If both variables are absolute numerical, then you can transform them into string and add like previously (easy solution) or use formula:
V1V2=nr*V1+V2, where nr is number of digits "0" to add into V1, so the digits number of V2, calculated as below:

compute nr=10.
compute #tmp=V2.
loop #i=1 to 10.
do if (#tmp&#62;10).
	compute #tmp=trunc(#tmp/10).
	compute nr=nr*10.
end if.
end loop.
exec.</description>
		<content:encoded><![CDATA[<p>For Wayne question (comment 3):</p>
<p>compute C=$sysmis.<br />
if (A=0 &amp; B=0) C=0.<br />
if (A=1 | B=1) C=1.<br />
exec.</p>
<p>For Thomas question (comment 5):<br />
If there are sting variables, use the CONCAT function (to join variables) and RTRIM function (to remove blanks).</p>
<p>If both variables are absolute numerical, then you can transform them into string and add like previously (easy solution) or use formula:<br />
V1V2=nr*V1+V2, where nr is number of digits &#8220;0&#8243; to add into V1, so the digits number of V2, calculated as below:</p>
<p>compute nr=10.<br />
compute #tmp=V2.<br />
loop #i=1 to 10.<br />
do if (#tmp&gt;10).<br />
	compute #tmp=trunc(#tmp/10).<br />
	compute nr=nr*10.<br />
end if.<br />
end loop.<br />
exec.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Thomas</title>
		<link>http://www.spsslog.com/2007/04/10/combine-two-variables-into-one/#comment-2644</link>
		<dc:creator>Thomas</dc:creator>
		<pubDate>Sun, 01 Jul 2007 05:57:34 +0000</pubDate>
		<guid isPermaLink="false">http://www.spsslog.com/2007/04/10/combine-two-variables-into-one/#comment-2644</guid>
		<description>I am still learning to SPSS, but my variable combination issue is different. I want to take the values of v1 and the values of v2 and put them in a new variable that has the values of v1v2. For example, v1 has a value of 1104 and v2 has a value of 34. I want to new variable to read 110434. It can be string of numerical. How do I do this? Thanks in advance for your assistance.</description>
		<content:encoded><![CDATA[<p>I am still learning to SPSS, but my variable combination issue is different. I want to take the values of v1 and the values of v2 and put them in a new variable that has the values of v1v2. For example, v1 has a value of 1104 and v2 has a value of 34. I want to new variable to read 110434. It can be string of numerical. How do I do this? Thanks in advance for your assistance.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Shawne</title>
		<link>http://www.spsslog.com/2007/04/10/combine-two-variables-into-one/#comment-2608</link>
		<dc:creator>Shawne</dc:creator>
		<pubDate>Thu, 28 Jun 2007 18:59:57 +0000</pubDate>
		<guid isPermaLink="false">http://www.spsslog.com/2007/04/10/combine-two-variables-into-one/#comment-2608</guid>
		<description>"This seems awfully simple but I havenâ€™t found the solution yet.

I want to combine 2 variables â€œAâ€ and â€œBâ€.
Each can be 0, 1, or missing.
If either is 1, then I want AB to be 1.
If BOTH are 0, then I want AB to be 0.
Otherwise I want AB to be missing."

Off the top of my head, you could try computing a new variable as "1" to account for A or B having a 1. You could then do an "IF" scenario where the new variable equals "0" provided that A and B equal 0. To give you an idea of the syntax:

COMPUTE C = 1.
IF (A = 0 AND B = 0) C = 0.

That is, your new variable will contain a zero under the condition that both A and B contain a 0. This assumes, however, that every case for A and B has a valid entry. Otherwise, you will potentially end up with C = 1 for instances where A and/or B have a missing value. To account for this, you could try creating an empty variable then apply the appropriate conditional statements for each outcome you want - if A = 1 and B = 0 then C = 1, etc.</description>
		<content:encoded><![CDATA[<p>&#8220;This seems awfully simple but I havenâ€™t found the solution yet.</p>
<p>I want to combine 2 variables â€œAâ€ and â€œBâ€.<br />
Each can be 0, 1, or missing.<br />
If either is 1, then I want AB to be 1.<br />
If BOTH are 0, then I want AB to be 0.<br />
Otherwise I want AB to be missing.&#8221;</p>
<p>Off the top of my head, you could try computing a new variable as &#8220;1&#8243; to account for A or B having a 1. You could then do an &#8220;IF&#8221; scenario where the new variable equals &#8220;0&#8243; provided that A and B equal 0. To give you an idea of the syntax:</p>
<p>COMPUTE C = 1.<br />
IF (A = 0 AND B = 0) C = 0.</p>
<p>That is, your new variable will contain a zero under the condition that both A and B contain a 0. This assumes, however, that every case for A and B has a valid entry. Otherwise, you will potentially end up with C = 1 for instances where A and/or B have a missing value. To account for this, you could try creating an empty variable then apply the appropriate conditional statements for each outcome you want - if A = 1 and B = 0 then C = 1, etc.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Wayne</title>
		<link>http://www.spsslog.com/2007/04/10/combine-two-variables-into-one/#comment-2055</link>
		<dc:creator>Wayne</dc:creator>
		<pubDate>Wed, 30 May 2007 01:00:36 +0000</pubDate>
		<guid isPermaLink="false">http://www.spsslog.com/2007/04/10/combine-two-variables-into-one/#comment-2055</guid>
		<description>This seems awfully simple but I haven't found the solution yet.

I want to combine 2 variables "A" and "B". 
Each can be 0, 1, or missing. 
If either is 1, then I want AB to be 1.
If BOTH are 0, then I want AB to be 0.
Otherwise I want AB to be missing.

Help??</description>
		<content:encoded><![CDATA[<p>This seems awfully simple but I haven&#8217;t found the solution yet.</p>
<p>I want to combine 2 variables &#8220;A&#8221; and &#8220;B&#8221;.<br />
Each can be 0, 1, or missing.<br />
If either is 1, then I want AB to be 1.<br />
If BOTH are 0, then I want AB to be 0.<br />
Otherwise I want AB to be missing.</p>
<p>Help??</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Andrea</title>
		<link>http://www.spsslog.com/2007/04/10/combine-two-variables-into-one/#comment-1957</link>
		<dc:creator>Andrea</dc:creator>
		<pubDate>Fri, 25 May 2007 16:44:12 +0000</pubDate>
		<guid isPermaLink="false">http://www.spsslog.com/2007/04/10/combine-two-variables-into-one/#comment-1957</guid>
		<description>What if there are overlapping records?  How would one combine two variables in order to know if respondants answered yes to either variable1 or variable2...to create a combined variable of "yes to either v1 or v2" or "no to both"?
Thanks.</description>
		<content:encoded><![CDATA[<p>What if there are overlapping records?  How would one combine two variables in order to know if respondants answered yes to either variable1 or variable2&#8230;to create a combined variable of &#8220;yes to either v1 or v2&#8243; or &#8220;no to both&#8221;?<br />
Thanks.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: ben</title>
		<link>http://www.spsslog.com/2007/04/10/combine-two-variables-into-one/#comment-1566</link>
		<dc:creator>ben</dc:creator>
		<pubDate>Sat, 12 May 2007 02:48:41 +0000</pubDate>
		<guid isPermaLink="false">http://www.spsslog.com/2007/04/10/combine-two-variables-into-one/#comment-1566</guid>
		<description>If both variables are numeric, all you have to do is recode each original variable so system-missing values = 0. Then simply compute the result variable = original1 + original2. That should do the trick. I'm assuming your data looks likethis:
v1     v2     res
2        .        .
5        .        .
.         9       .
.         7       .

so recode v1 and v2 to look like this:
v1     v2     res
2        0       .
5        0       .
0        9       .
0        7       .
then when result is the sum of v1+v2 it will be:
res
2
5
9
7</description>
		<content:encoded><![CDATA[<p>If both variables are numeric, all you have to do is recode each original variable so system-missing values = 0. Then simply compute the result variable = original1 + original2. That should do the trick. I&#8217;m assuming your data looks likethis:<br />
v1     v2     res<br />
2        .        .<br />
5        .        .<br />
.         9       .<br />
.         7       .</p>
<p>so recode v1 and v2 to look like this:<br />
v1     v2     res<br />
2        0       .<br />
5        0       .<br />
0        9       .<br />
0        7       .<br />
then when result is the sum of v1+v2 it will be:<br />
res<br />
2<br />
5<br />
9<br />
7</p>
]]></content:encoded>
	</item>
</channel>
</rss>
