Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Concatenating three variables in SPSS

33 views
Skip to first unread message

Phil

unread,
Mar 18, 2005, 10:38:15 AM3/18/05
to
I have a dataset that I wish to analyze. However, there are six files
to it and I want to merge them. First however I want to combine three
numeric fields in each file to form one unique field. The variables
are DID, CN, and FER, all nominal variables. I have tried to use the
recode option but when I go into that window, I find that I cannot put
the arguments that my friend said I should use in the windows provided.
My friend said I should do this:

To create a new variable, (var_123), you would do:
If var_1=1, and var_2 = 1, and var_3 =1, then var_123 =1

If this approach is right, I have no way of knowing since I cannot even
put it down in SPSS.

Another friend suggested the following:Compute DIDCNFER =
CONCATINATE(StrExpr1,StrExpr2,StrExpr3)
However am not sure this will work because from this website, I learned
that this approach may not work but even then I do not know how to
write it in the compute option of SPSS.

I am receptive to any suggestions if anybody has an answer.

Thanks.

Art Kendall

unread,
Mar 18, 2005, 11:33:50 AM3/18/05
to
The output variable needs to have as many characters as the sum of the
previous three strings.
say DID has 4 CN 2 and FER 3 then
something like this untested syntax should work.
string DIDCNFER (A9).
COMPUTE DIDCNFER = CONCAT(DID,CN,FER).
AUTORECODE DIDCNFER INTO UNIQUEID.

If the three variables are numeric you might do something like
numeric DIDCNFER (N9).
compute DIDCNFER = 100000*DID + 10000*CN + 1000*FER.
RECODE is a particular kind of transformation.
CONCAT is a string function.

Did someone perhaps suggest AUTORECODE so that the values of new
variables are consecutive integers?

How many values do each of DID CN and FER HAVE? Are they nominal or
string variables? what do you want to do when the 3 variables have
different values?


Please explain in more detail wHat you are trying to do.

Perhaps you should make up a mini data set with 4 variables
something like this
new file.
data list list /DID(a4) CN(a2) FER(a3) WANT (a9).
begin data
'1' '1' '1' '1'
'1' '1' 'A' '11A'
'7321' 'AB' 'XYZ' '7321ABXYZ'
. . .

or something like this
data list list /DID CN FER WANT .
begin data
1 1 1 1
1 1 2 2
1 1 3 3
1 2 1 4
1 2 2 5
1 3 3 6
. . .
3 3 3 27
end data.

Art
A...@DrKendall.org
Social Research Consultants
University Park, MD USA
(301) 864-5570

Feyo

unread,
Mar 18, 2005, 12:58:41 PM3/18/05
to
A shot in the dark - are you trying to combine these three variables so
that you can merge on them? If so, there is no need because you can use
multiple /BY variables to merge files.

For example:

MATCH FILES FILE=*
/FILE='c:\somefile.sav'
/BY DID CN FER.
EXE.

I may be way off with respect to your reason for wanting to combine
these variables, but...

0 new messages