Reputation: 21
So, I've been using SPSS for not so long and I need help creating a variable using two others.
I have a survey, and a variable of "household number" for each person and another variable of "relationship with household head" (head=1, spouse=2, child=3 etc). I want to create a variable of "type of family" by using the relationship with household head in each household.
So, something like:
If in the household there's only the head, then is 1
If there's the head, spouse and/or children, then is 2
If it's head plus any other type of relative, it's 3.
Eg:
Household Nº - Relationship
1 - 1
1 - 2
1 - 3
In the household "1" there is a head (1), a spouse (2) and a child (3), so it would be a "type of family" 2.
I don't know what commands to use for doing this is SPPS. Can anyone help me?
Upvotes: 2
Views: 1329
Reputation: 5089
I suspect this will require the use of AGGREGATE
to assign needed characteristics to all family members and then use of if statements to make the family types. So lets start with some example data similar to yours. This makes a set of families in long format.
data list free / house relation.
begin data
1 1
1 2
1 3
2 1
3 1
3 2
4 1
4 3
5 1
5 2
5 3
5 3
5 3
end data.
VALUE LABELS relation
1 'Head'
2 'Spouse'
3 'Child'.
From here I will suggest four types of families; Single-No Children
, Couple-No Children
, Single-With Children
, and Couple-With Children
. To get these, I make a dummy variable to indicate whether a case is a child or a spouse, and then aggregate the minimum value within family to provide a flag for if the family has any spouse or any child.
*Make flag for if have a spouse and if have a child.
COMPUTE child = (relation EQ 3).
COMPUTE spouse = (relation EQ 2).
*Aggregate to get a flag for child or spouse.
AGGREGATE
/OUTFILE=* MODE=ADDVARIABLES
/BREAK=house
/AnyChild = MAX(child)
/AnySpouse = MAX(spouse)
/NumChild=SUM(child)
/TotalFamSize=N.
I also show how one can get the total number of children using SUM
and the total family size using N
in the aggregate command. From here you can use a series of if statements to categorize the different types of families.
*From here can make several fam categories using DO IF.
DO IF TotalFamSize = 1.
COMPUTE FamType = 1.
ELSE IF AnySpouse = 1 AND AnyChild = 0.
COMPUTE FamType = 2.
ELSE IF AnySpouse = 0 and AnyChild = 1.
COMPUTE FamType = 3.
ELSE IF AnySpouse = 1 and AnyChild = 1.
COMPUTE FamType = 4.
END IF.
VALUE LABELS FamType
1 'Single - No Children'
2 'Couple - No Children'
3 'Single - Children'
4 'Couple - Children'.
EXECUTE.
This logic of using aggregate to get statistics for the whole family should be amenable to whatever types of stats you want to generate.
Upvotes: 1