putting the values of 5 different numeric variables into one numeric variable

putting the values of 5 different numeric variables into one numeric variable

Post by Tom » Fri, 23 Dec 2005 18:17:53


Hello everybody,

it is probably a very simple question but what I want to achieve in
SPSS and I will show it with one row:

var1 var2 var3 var4 var5
values 2 3 7 9 1

then create one variable:

var6

23791

in order to have an identification number(variable),

thanks,

Tom
 
 
 

putting the values of 5 different numeric variables into one numeric variable

Post by Michael.La » Sat, 24 Dec 2005 00:39:22


compute var6 = var5 + 10*var4 + 100* var3 + 1000*var2 + 10000*var1 .

If 0 is a possible value for var1, and you would like to make
sure it displays, you will need to make var6 a string:

string var6 (a5) .
do repeat v = v6 v5 v4 v3 v2 v1 .
compute var6 = concat(var6,string(v,f1.0)) .
end repeat .


--
=-=-=-=-=-=-=-=-=-==-=-=-=
Mike Lacy, Ft Collins CO 80523
Clean out the 'junk' to email me.

 
 
 

putting the values of 5 different numeric variables into one numeric variable

Post by Nesto » Sat, 24 Dec 2005 01:01:27

var6 = var5 + (var4 * 10) + (var3 * 100) + (var2 * 1000) + (var1 *
10000).
 
 
 

putting the values of 5 different numeric variables into one numeric variable

Post by fred.sutto » Sat, 24 Dec 2005 17:32:44

You could try
comp
var6=number(concat(string(var1,f1),string(var2,f1),string(var3,f1),string(var4,f1),string(var5,f1)),f5).
exe.