Search code examples
statisticsspss

How to filter values of a variable


For a school assignment I'm currently working with SPSS and want to analyse a data package we received from our client. For instance; when I have got three variables, two being gender, age and the third one's the kind of drink respondents consume at the start of the day. In my analysis I only want to see the percentage of men between 20 and 30 drinking coffee. What function do I have to use to accomplish such thing?

Thanks in advance! Emiel


Solution

  • Here are a couple of possibilities to start you off on SPSS syntax:

    If you just want the answer to get this percent you could do this -

    compute dr_cofee=(drink="Cofee").
    value labels dr_cofee
    0 "other drinks"
    1 "cofee".
    compute men20_30=range(age, 20, 30) and gender="men".
    filter by men20_30.
    freq dr_cofee.
    filter off.
    

    On the other hand you could generalize your analysis.
    First create age groups, then analyze within each AgeGroup:

    recode age (1 thru 19=1)(20 thru 29=2)(30 thru 39=3)([continue as needed]) into AgeGroup. 
    value labels AgeGroup
    1 "ages 1 - 19"
    2 "ages 20 - 29". /* continue as needed.
    sort cases by gender AgeGroup.
    split file by gender AgeGroup.
    freq Drink.
    split file off.