Return to Video

Computing a new variable in SPSS

  • 0:00 - 0:03
    >> So here we are in SPSS.
  • 0:03 - 0:05
    I have created a junk data
  • 0:05 - 0:07
    set just to help
    illustrate how we can
  • 0:07 - 0:09
    compute variables
    or compute
  • 0:09 - 0:10
    new variables using
  • 0:10 - 0:12
    the values from
    existing ones.
  • 0:12 - 0:14
    This is a pretty
    straightforward process.
  • 0:14 - 0:15
    It looks a little bit
  • 0:15 - 0:17
    different than things
    that we've done
  • 0:17 - 0:19
    before or other
    ways that we're
  • 0:19 - 0:21
    going to be using
    SPSS in this course.
  • 0:21 - 0:22
    So it might look a
    little bit different,
  • 0:22 - 0:24
    but it is pretty
    straightforward and
  • 0:24 - 0:26
    pretty easy once you
    know how to do this.
  • 0:26 - 0:28
    So the first
    thing that we'll
  • 0:28 - 0:29
    do is go to Transform,
  • 0:29 - 0:31
    and then the
    first option we
  • 0:31 - 0:32
    have there is
    compute variable.
  • 0:32 - 0:34
    So click on that. We get
  • 0:34 - 0:36
    this new window
    that pops up.
  • 0:36 - 0:38
    The first thing
    that we really want
  • 0:38 - 0:39
    to look at is in
    the top left,
  • 0:39 - 0:43
    and that's this target
    variable window.
  • 0:43 - 0:44
    Basically what
    the computer
  • 0:44 - 0:46
    is asking you is to create
  • 0:46 - 0:48
    a name for the
    new variable
  • 0:48 - 0:49
    that you're going
    to be computing.
  • 0:49 - 0:51
    This name needs
    to be unique,
  • 0:51 - 0:53
    it's one that can't
    have spaces in it,
  • 0:53 - 0:55
    and it should avoid
    special characters.
  • 0:55 - 0:57
    But, in this case,
  • 0:57 - 0:59
    what I like to
    do is include
  • 0:59 - 1:01
    some piece of
    information in there
  • 1:01 - 1:04
    in the naming
    convention I use that
  • 1:04 - 1:05
    helps me know what this is
  • 1:05 - 1:06
    just by looking at it.
  • 1:06 - 1:08
    So what we're going
    to be doing is
  • 1:08 - 1:10
    we're going to be
    summing items 1,
  • 1:10 - 1:11
    2, 3, 4, 5,
  • 1:11 - 1:13
    and 6 together, adding
    those together.
  • 1:13 - 1:14
    So an easy way
    to do that is
  • 1:14 - 1:17
    just to put sumofitems.
  • 1:17 - 1:20
    That way, when I look at
  • 1:20 - 1:22
    this new variable
    once it's generated,
  • 1:22 - 1:23
    I know that that's
    the variable
  • 1:23 - 1:25
    that I really want
    to be working
  • 1:25 - 1:27
    with or running
    my tests on
  • 1:27 - 1:28
    because that contains
  • 1:28 - 1:30
    the information from
    the other ones.
  • 1:30 - 1:33
    You can click on
    Type & Label.
  • 1:33 - 1:36
    The label is the more
    drawn-out explanation.
  • 1:36 - 1:38
    That's one that
    you can include
  • 1:38 - 1:39
    additional characters or
  • 1:39 - 1:41
    spaces and special
    characters.
  • 1:41 - 1:43
    In our case, I'm
    going to put this is
  • 1:43 - 1:49
    the sum of items
    1 through 6.
  • 1:49 - 1:51
    And that way I know that
  • 1:51 - 1:53
    that is going to give me
  • 1:53 - 1:55
    a more drawn-out
    explanation
  • 1:55 - 1:57
    of what this
    variable includes.
  • 1:57 - 1:59
    We know this is
    going to be numeric.
  • 1:59 - 2:01
    So click Continue.
  • 2:01 - 2:03
    The next thing we're
    going to look at
  • 2:03 - 2:05
    is this numeric
    expression box.
  • 2:05 - 2:07
    And will actually
    come back
  • 2:07 - 2:08
    to this in just a minute,
  • 2:08 - 2:08
    but this is where you're
  • 2:08 - 2:09
    going to be doing most
  • 2:09 - 2:11
    of the work when you're
    computing a variable.
  • 2:11 - 2:13
    What you'll want
    to go to next
  • 2:13 - 2:15
    is this function
    group area.
  • 2:15 - 2:17
    So I'm going to
    click on All.
  • 2:17 - 2:19
    And you notice right
    below it we've
  • 2:19 - 2:21
    got these functions
    and special variables,
  • 2:21 - 2:23
    and this popped up
    when I clicked on All.
  • 2:23 - 2:25
    This has a whole bunch of
  • 2:25 - 2:26
    different pre-existing
    functions,
  • 2:26 - 2:28
    so you don't need to
    reinvent the wheel,
  • 2:28 - 2:29
    you can basically use
  • 2:29 - 2:31
    these pre-existing
    functions to
  • 2:31 - 2:33
    help you compute
    this new variable.
  • 2:33 - 2:35
    I'm going to go
    down to sum,
  • 2:35 - 2:36
    and these are in
    alphabetical order,
  • 2:36 - 2:38
    so it's pretty
    easy to find.
  • 2:38 - 2:40
    Here we have sum, and
    when I click on sum,
  • 2:40 - 2:41
    you'll notice
    that this box on
  • 2:41 - 2:44
    the left populated
    with some text.
  • 2:44 - 2:46
    This box is actually
    pretty useful.
  • 2:46 - 2:48
    So the first thing
    it shows you is
  • 2:48 - 2:49
    an example of what
  • 2:49 - 2:50
    this expression
    is going to be.
  • 2:50 - 2:52
    And our expression
    sounds like
  • 2:52 - 2:53
    a really fancy term.
  • 2:53 - 2:54
    If you've ever
    used a formula
  • 2:54 - 2:56
    in Excel, it's
    basically that.
  • 2:56 - 2:57
    It's telling the computer
  • 2:57 - 2:58
    what it needs to do.
  • 2:58 - 3:01
    In this case,
    just like Excel,
  • 3:01 - 3:02
    we've got the word sum,
  • 3:02 - 3:04
    which tells the computer
    it's going to be
  • 3:04 - 3:05
    summing different
    values together,
  • 3:05 - 3:07
    and then in parentheses,
  • 3:07 - 3:08
    immediately after that,
  • 3:08 - 3:09
    we have different
    variables
  • 3:09 - 3:11
    that are separated
    by a comma,
  • 3:11 - 3:12
    and that's what tells the
  • 3:12 - 3:13
    computer to add x, y,
  • 3:13 - 3:15
    and z things
    together to create
  • 3:15 - 3:18
    a new variable or
    compute a new variable.
  • 3:18 - 3:19
    This also provides
  • 3:19 - 3:21
    additional extra
    content here,
  • 3:21 - 3:22
    but we don't need to
    worry about that.
  • 3:22 - 3:24
    I found this is
    helpful if you
  • 3:24 - 3:26
    are stuck or something
    isn't working right.
  • 3:26 - 3:28
    So we've got sum selected,
  • 3:28 - 3:30
    we're going to be
    summing the items of 1,
  • 3:30 - 3:32
    2, 3, 4, 5, and
    6 together.
  • 3:32 - 3:33
    We've got that selected.
  • 3:33 - 3:34
    So the next thing you do
  • 3:34 - 3:35
    is click this up arrow,
  • 3:35 - 3:36
    which basically takes
  • 3:36 - 3:38
    that pre-existing function
  • 3:38 - 3:40
    and it kicks it up
    to this numeric
  • 3:40 - 3:42
    and expression box.
  • 3:42 - 3:44
    The next thing that
    we're going to do,
  • 3:44 - 3:45
    we've already told
  • 3:45 - 3:46
    the computer
    that we're going
  • 3:46 - 3:48
    to sum different
    variables together,
  • 3:48 - 3:49
    we need to tell it which
  • 3:49 - 3:50
    variables to sum together.
  • 3:50 - 3:53
    So the easy way
    to do this is to
  • 3:53 - 3:54
    click on the first
  • 3:54 - 3:55
    item that you
    want to include,
  • 3:55 - 3:58
    and you'll notice
    that this arrow
  • 3:58 - 3:59
    switch sides from pointing
  • 3:59 - 4:01
    to the left to
    pointing to the right,
  • 4:01 - 4:02
    click over 1,
  • 4:02 - 4:04
    and we've already
    moved over item 1.
  • 4:04 - 4:07
    What you need to be
    careful of is that you
  • 4:07 - 4:10
    always have a comma
    after each variable,
  • 4:10 - 4:11
    except for the last one.
  • 4:11 - 4:13
    So a comma is
    already here,
  • 4:13 - 4:15
    but what I usually do
    is I just hit a comma,
  • 4:15 - 4:17
    I go to item 2,
  • 4:17 - 4:19
    kick that over, comma,
  • 4:19 - 4:21
    item 3, kick that over,
  • 4:21 - 4:24
    comma, item 4,
    kick that over,
  • 4:24 - 4:25
    comma, item 5,
  • 4:25 - 4:27
    kick that over, comma,
  • 4:27 - 4:29
    item 6, kick that over.
  • 4:29 - 4:30
    Now, we know that item 6
  • 4:30 - 4:32
    is the last one we have,
  • 4:32 - 4:34
    the last variable
    we're including,
  • 4:34 - 4:35
    so what we're
    going to do is
  • 4:35 - 4:37
    just delete out
    that question mark,
  • 4:37 - 4:39
    we're going to delete
    out that last comma,
  • 4:39 - 4:40
    and then if we read
    through this real quick
  • 4:40 - 4:41
    just to make sure we
  • 4:41 - 4:42
    don't have any problems,
  • 4:42 - 4:45
    we've got creating
    sumofitems,
  • 4:45 - 4:47
    this is going to
    be the sum of
  • 4:47 - 4:48
    item 1, 2, 3,
  • 4:48 - 4:51
    4, 5, and 6,
  • 4:51 - 4:54
    and what we're going
    to do now is click OK.
  • 4:54 - 4:57
    An output window pops
  • 4:57 - 4:58
    up and it basically tells
  • 4:58 - 4:59
    you what the computer did.
  • 4:59 - 5:00
    It computed the
    sum of items,
  • 5:00 - 5:02
    which was the
    sum of item 1,
  • 5:02 - 5:03
    2, 3, 4, 5, and 6,
  • 5:03 - 5:05
    it gives us the
    variable label,
  • 5:05 - 5:09
    it gives us that
    descriptive text I put in.
  • 5:09 - 5:10
    I'm just going to
    minimize this window,
  • 5:10 - 5:11
    and if we look back here,
  • 5:11 - 5:12
    you might notice that
  • 5:12 - 5:14
    there's this new column,
  • 5:14 - 5:16
    this new variable,
    that sumofitems,
  • 5:16 - 5:17
    that wasn't there
    when we started,
  • 5:17 - 5:19
    and that's because
    SPSS computed that.
  • 5:19 - 5:21
    And if we add
    these together,
  • 5:21 - 5:22
    if you add each row,
  • 5:22 - 5:24
    we've got 1, 2, 1, 3, 5,
  • 5:24 - 5:27
    1, that adds to 13,
  • 5:27 - 5:28
    5, 1, 2,
  • 5:28 - 5:30
    3, 5, 1 adds to 17.
  • 5:30 - 5:32
    So it's done that
    math for us.
  • 5:32 - 5:33
    We didn't have to
    manually do it.
  • 5:33 - 5:36
    I know, yes, it'd
    be pretty easy to
  • 5:36 - 5:38
    manually do this
    for 10 cases,
  • 5:38 - 5:41
    but if you have a dataset
    that has 500 cases,
  • 5:41 - 5:43
    that would be very
    time-consuming to do.
  • 5:43 - 5:45
    And you could see
    that this function of
  • 5:45 - 5:47
    computing this
    variable can
  • 5:47 - 5:48
    save you a lot of time.
  • 5:48 - 5:50
    It's also more accurate.
  • 5:50 - 5:51
    It's going to
    take any error
  • 5:51 - 5:54
    out of the equation.
  • 5:54 - 5:55
    And we know that often
  • 5:55 - 5:56
    when we do things by hand,
  • 5:56 - 5:58
    we can introduce
    error into things,
  • 5:58 - 6:00
    so we want to avoid that.
  • 6:00 - 6:02
    That's one way to
    computer a variable.
  • 6:02 - 6:05
    I'm going to show
    you a different type
  • 6:05 - 6:06
    of variable that
    we can compute.
  • 6:06 - 6:08
    I'm going to go
    back to Transform,
  • 6:08 - 6:10
    I'm going to go back
    to Compute Variable.
  • 6:10 - 6:11
    I'm actually going
    to clear this out.
  • 6:11 - 6:13
    We're done with
    someofitems,
  • 6:13 - 6:14
    we don't need to
    worry about it,
  • 6:14 - 6:15
    we're not going to use
    the same expression,
  • 6:15 - 6:16
    so I'm going to click
  • 6:16 - 6:18
    Reset in the bottom here.
  • 6:18 - 6:20
    So what I want
    to do is create
  • 6:20 - 6:23
    the mean of the different
    items that we have.
  • 6:23 - 6:24
    Sometimes if
    you're working
  • 6:24 - 6:26
    with a pre-existing scale,
  • 6:26 - 6:28
    it might tell you to add
  • 6:28 - 6:30
    all the items
    together and then
  • 6:30 - 6:31
    that's what represents
  • 6:31 - 6:34
    that theoretical concept
    or that measure,
  • 6:34 - 6:36
    sometimes it might tell
    you to use the mean.
  • 6:36 - 6:39
    So what I want to do
    is compute both of
  • 6:39 - 6:40
    these things because they
  • 6:40 - 6:41
    both might be
    helpful to me.
  • 6:41 - 6:43
    So what I'm going to do is
  • 6:43 - 6:45
    I'm going to type
    meanofitems.
  • 6:45 - 6:47
    And again, that very
    quickly lets me
  • 6:47 - 6:48
    differentiate between
  • 6:48 - 6:50
    sumofitems and
    meanofitems.
  • 6:50 - 6:52
    Type & label, and again,
  • 6:52 - 6:55
    I'm just going to put
    mean of items 1 through
  • 6:55 - 7:02
    6, click Continue.
  • 7:02 - 7:05
    Just like we did
    before, click on All,
  • 7:05 - 7:06
    and then we're
    going to go down
  • 7:06 - 7:10
    to mean, here's mean.
  • 7:10 - 7:12
    And when I click
    on that, again,
  • 7:12 - 7:14
    it gives me that
    sample text here.
  • 7:14 - 7:17
    This is very similar
    to what we did before.
  • 7:17 - 7:19
    I'm going to click up, and
  • 7:19 - 7:22
    we're going to
    kick over 1,
  • 7:22 - 7:30
    2, 3, 4, 5, and then 6.
  • 7:30 - 7:31
    I'm making sure to not
  • 7:31 - 7:34
    include this last
    one, this sumofitems.
  • 7:34 - 7:35
    And then just
    like last time,
  • 7:35 - 7:36
    we're going to delete out
  • 7:36 - 7:37
    that question mark,
    that last comma.
  • 7:37 - 7:39
    We're going to
    read through
  • 7:39 - 7:41
    it really quickly just
    to avoid an error.
  • 7:41 - 7:43
    We've got a new
    variable, meanofitems.
  • 7:43 - 7:45
    It's going to be
    the mean of item 1,
  • 7:45 - 7:47
    2, 3, 4, 5, and 6.
  • 7:47 - 7:51
    I'm going to
    click OK. SPSS
  • 7:51 - 7:54
    again showed me the
    syntax of what it did.
  • 7:54 - 7:56
    I'm going to
    minimize that.
  • 7:56 - 7:58
    And then here we have
    the mean of items.
  • 7:58 - 8:00
    And if we really
    quickly look at this,
  • 8:00 - 8:02
    I'm going to pick this
    one, for example,
  • 8:02 - 8:04
    we've got 1,
  • 8:04 - 8:06
    1, 3, 3, 1, 2,
  • 8:06 - 8:08
    and a mean of 1.83 would,
  • 8:08 - 8:10
    just eyeballing
    it, make sense.
  • 8:10 - 8:12
    If we look at this one,
  • 8:12 - 8:14
    3.67, 2,
  • 8:14 - 8:16
    3, 5, 4, 5, 3,
  • 8:16 - 8:17
    that would roughly
    make sense
  • 8:17 - 8:19
    without having to
    do the math of it,
  • 8:19 - 8:21
    but this has computed
    the average score,
  • 8:21 - 8:24
    the mean score for all
    six of those items.
  • 8:24 - 8:27
    So that is very
    quickly how to
  • 8:27 - 8:29
    compute a new
    variable in SPSS.
  • 8:29 - 8:30
    This is
    particularly useful
  • 8:30 - 8:32
    when you have
    collected data using
  • 8:32 - 8:35
    a pre-existing measure
    and that measure has
  • 8:35 - 8:36
    instructed you to compute
  • 8:36 - 8:39
    the sum of items and
    run your tests on that,
  • 8:39 - 8:40
    or maybe the mean of items
  • 8:40 - 8:41
    and run your
    tests on that.
  • 8:41 - 8:43
    But this is a useful way
  • 8:43 - 8:44
    of understanding
    how to create
  • 8:44 - 8:48
    new variables using
    existing ones in SPSS.
Title:
Computing a new variable in SPSS
Description:

more » « less
Video Language:
English
Duration:
08:48

English subtitles

Revisions Compare revisions