merging for variables into one

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

merging for variables into one

Talino Bruno
I have four variables ext, int, co-occur, no problem and that are all
categorical with subjects in the ext variable being labeled 1 if they meet
the criteria and 0 if not, for int the number  is 2, co-occur it’s 3 and no
problem its 4. 0 if not meet criteria. I would like to merge these four
variables into one NEW variable so that the NEW variable has four
categories:
ext: value 1
Int: value 2
co-occur: value 3
no problem: value 4

How can I do this?

=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (not to SPSSX-L), with no body text except the
command. To leave the list, send the command
SIGNOFF SPSSX-L
For a list of commands to manage subscriptions, send the command
INFO REFCARD
Reply | Threaded
Open this post in threaded view
|

Re: merging for variables into one

David Wasserman
Using syntax, and assuming that no case has more than one nonzero value for the four variables:

compute newvar = sum(ext,int,co_occur,no_problem).

(using the real variable names, of course.)

-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Talino Bruno
Sent: February-07-09 1:38 AM
To: [hidden email]
Subject: merging for variables into one

I have four variables ext, int, co-occur, no problem and that are all
categorical with subjects in the ext variable being labeled 1 if they meet
the criteria and 0 if not, for int the number  is 2, co-occur it’s 3 and no
problem its 4. 0 if not meet criteria. I would like to merge these four
variables into one NEW variable so that the NEW variable has four
categories:
ext: value 1
Int: value 2
co-occur: value 3
no problem: value 4

How can I do this?

=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (not to SPSSX-L), with no body text except the
command. To leave the list, send the command
SIGNOFF SPSSX-L
For a list of commands to manage subscriptions, send the command
INFO REFCARD

=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (not to SPSSX-L), with no body text except the
command. To leave the list, send the command
SIGNOFF SPSSX-L
For a list of commands to manage subscriptions, send the command
INFO REFCARD
Reply | Threaded
Open this post in threaded view
|

Re: merging for variables into one

Melissa Ives
I don't believe that example will do what Talino wants.
For example, in order to get no-problem=4 in that syntax, int, ext, co-occur AND no problem would all need to be coded 1-Yes, it is illogical to have co-occur and no problem both being yes.

Try this...it is an untested modification of syntax we  use to calculate int_ext. We chose to code no problem=0 and co-occuring either 3 (as the highest risk) or 2 so it would appear in pie charts between internal and external thereby allowing a simple sum of percents to get total with any internal and total with any external.

We only calculate this with int and ext, but since you have co-occur and no problem, I incorporated those--with co-occur requiring only that either co-occur is yes or that both int and ext are yes; and no problem reqiring int, ext  and co-occur to be 0=No.

if (int=0 and ext=1) int_ext=1.
if (int=1 and ext=0) int_ext=2.
if ((int=1 and ext=1) or co-occur=1 int_ext=3.
if (int=0 and ext=0 and co-occur=0 and no problem=1) int_ext=4.

*** alternate calculation for no problem--depending upon how you want to handle missing values (and whether there are any).  You could change the sum.3 to sum.2 or suum.1.
If (sum.3(int,ext,co-occur)=0 and no problem=1) int_ext=4.


Melissa Ives

[hidden email]
voice: 309-451-7819


-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of David Wasserman
Sent: Saturday, February 07, 2009 7:59 AM
To: [hidden email]
Subject: Re: [SPSSX-L] merging for variables into one

Using syntax, and assuming that no case has more than one nonzero value for the four variables:

compute newvar = sum(ext,int,co_occur,no_problem).

(using the real variable names, of course.)

-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Talino Bruno
Sent: February-07-09 1:38 AM
To: [hidden email]
Subject: merging for variables into one

I have four variables ext, int, co-occur, no problem and that are all categorical with subjects in the ext variable being labeled 1 if they meet the criteria and 0 if not, for int the number  is 2, co-occur it’s 3 and no problem its 4. 0 if not meet criteria. I would like to merge these four variables into one NEW variable so that the NEW variable has four
categories:
ext: value 1
Int: value 2
co-occur: value 3
no problem: value 4

How can I do this?

=====================
To manage your subscription to SPSSX-L, send a message to [hidden email] (not to SPSSX-L), with no body text except the command. To leave the list, send the command SIGNOFF SPSSX-L For a list of commands to manage subscriptions, send the command INFO REFCARD

=====================
To manage your subscription to SPSSX-L, send a message to [hidden email] (not to SPSSX-L), with no body text except the command. To leave the list, send the command SIGNOFF SPSSX-L For a list of commands to manage subscriptions, send the command INFO REFCARD

PRIVILEGED AND CONFIDENTIAL INFORMATION
This transmittal and any attachments may contain PRIVILEGED AND
CONFIDENTIAL information and is intended only for the use of the
addressee. If you are not the designated recipient, or an employee
or agent authorized to deliver such transmittals to the designated
recipient, you are hereby notified that any dissemination,
copying or publication of this transmittal is strictly prohibited. If
you have received this transmittal in error, please notify us
immediately by replying to the sender and delete this copy from your
system. You may also call us at (309) 827-6026 for assistance.

=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (not to SPSSX-L), with no body text except the
command. To leave the list, send the command
SIGNOFF SPSSX-L
For a list of commands to manage subscriptions, send the command
INFO REFCARD
Reply | Threaded
Open this post in threaded view
|

Re: merging for variables into one

Fry, Jonathan B.
In reply to this post by Talino Bruno
Assuming a case can have a 1 in at most one of these variables, perhaps something like

Compute newVar = ext + Int*2 + co_occur*3 + no_problem*4.

Jonathan Fry

-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Talino Bruno
Sent: Saturday, February 07, 2009 2:38 AM
To: [hidden email]
Subject: merging for variables into one

I have four variables ext, int, co-occur, no problem and that are all
categorical with subjects in the ext variable being labeled 1 if they meet
the criteria and 0 if not, for int the number  is 2, co-occur it’s 3 and no
problem its 4. 0 if not meet criteria. I would like to merge these four
variables into one NEW variable so that the NEW variable has four
categories:
ext: value 1
Int: value 2
co-occur: value 3
no problem: value 4

How can I do this?

=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (not to SPSSX-L), with no body text except the
command. To leave the list, send the command
SIGNOFF SPSSX-L
For a list of commands to manage subscriptions, send the command
INFO REFCARD

=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (not to SPSSX-L), with no body text except the
command. To leave the list, send the command
SIGNOFF SPSSX-L
For a list of commands to manage subscriptions, send the command
INFO REFCARD