Discussion:
Create New Variable Where Categories Added Together
(too old to reply)
Emily
2018-05-17 21:48:14 UTC
Permalink
Alright y'all, I need to create a newvar, let's call it "Identity". The variable is whether survey respondents are cancer survivors, cancer caregivers, or folks who have been both a cancer survivor and caregiver. The way the data is recorded it's currently three categories (Survivors, Caregivers, or Boths), but I need TWO categories: 1) All Survivors and 2) All Caregivers.

The original data as is:

Group
1 = Survivors
2 = Caregivers
3 = Both Survivor and Caregiver

To be clear: some respondents are ONLY Survivors, some ONLY caregivers, and then a third group of people who identity as being BOTH survivors and caregivers. What I need:

NewVar
1 = "All Survivors"
2 = "All Caregivers"

To clarify a bit more, I'll give some hypothetical n's... let's say Survivors n = 50, Caregivers n = 40, and Boths n = 20. So ALL SURVIVORS would be n = 70, and ALL CAREGIVERS would be n = 60.

I need to combine 1 AND 3 for the first category, and 2 AND 3 for the second category. I think the code will look something like this:

COMPUTE Identity=. (???)
IF (Group = 1 AND 3) Identity = 1.
IF (Group = 2 AND 3) Identity = 2.
VALUE LABELS Identity
1 "All Survivors"
2 "All Caregivers".
FREQUENCIES VARIABLES=Identity

Any help appreciated!!!
Rich Ulrich
2018-05-18 03:26:06 UTC
Permalink
Post by Emily
Alright y'all, I need to create a newvar, let's call it "Identity". The variable is whether survey respondents are cancer survivors, cancer caregivers, or folks who have been both a cancer survivor and caregiver. The way the data is recorded it's currently three categories (Survivors, Caregivers, or Boths), but I need TWO categories: 1) All Survivors and 2) All Caregivers.
Group
1 = Survivors
2 = Caregivers
3 = Both Survivor and Caregiver
NewVar
1 = "All Survivors"
2 = "All Caregivers"
To clarify a bit more, I'll give some hypothetical n's... let's say Survivors n = 50, Caregivers n = 40, and Boths n = 20. So ALL SURVIVORS would be n = 70, and ALL CAREGIVERS would be n = 60.
There's your fatal, logical problem, right there.

If you have N=110, you cannot possibly have one
variable where the counts of categories add up to 130.

Any testing that you ought to be doing will use exclusive
categories, or you won't have legitimate tests.

To go into comparison of two groups and not three,
you might want to create two new variables, for "all
survivors" and for "all caregivers."

RECODE Group(1,3=1)(else=2)/into AllSurv/
Group(2,3)=1)(else=2)/into AllCare.

That gives you 1=Yes and 2=No for membership in
the wider groups.
Post by Emily
COMPUTE Identity=. (???)
IF (Group = 1 AND 3) Identity = 1.
- That's not legal syntax in SPSS -
It will test (1) Is Group=1? ... the answer is True "1" or False "0" ;
it will test (2) is that resulting 0 or 1 equals 3? ... the answer is
False in both instances, so the assignment is skipped.

The logic you seek is shown in
IF ((Group eq 1) or (Group eq 3)) Identity=1.

Especially for longer sets of choices, you start with
something like,

IF ANY(Group, 1, 3) Identity= 1.
Post by Emily
IF (Group = 2 AND 3) Identity = 2.
VALUE LABELS Identity
1 "All Survivors"
2 "All Caregivers".
FREQUENCIES VARIABLES=Identity
Any help appreciated!!!
--
Rich Ulrich
Emily
2018-05-18 21:22:35 UTC
Permalink
Post by Emily
Alright y'all, I need to create a newvar, let's call it "Identity". The variable is whether survey respondents are cancer survivors, cancer caregivers, or folks who have been both a cancer survivor and caregiver. The way the data is recorded it's currently three categories (Survivors, Caregivers, or Boths), but I need TWO categories: 1) All Survivors and 2) All Caregivers.
Group
1 = Survivors
2 = Caregivers
3 = Both Survivor and Caregiver
NewVar
1 = "All Survivors"
2 = "All Caregivers"
To clarify a bit more, I'll give some hypothetical n's... let's say Survivors n = 50, Caregivers n = 40, and Boths n = 20. So ALL SURVIVORS would be n = 70, and ALL CAREGIVERS would be n = 60.
COMPUTE Identity=. (???)
IF (Group = 1 AND 3) Identity = 1.
IF (Group = 2 AND 3) Identity = 2.
VALUE LABELS Identity
1 "All Survivors"
2 "All Caregivers".
FREQUENCIES VARIABLES=Identity
Any help appreciated!!!
Thank you, the first code worked well for me. No, no I wasn't going to test the groups against each other. I realize the groups would overlap and therefore it doesn't make logical sense. I just need the "alls" grouped together in their two groups so I can run some analyses with all members of the two separate groups, separately. Thanks.
Loading...