WEBVTT 00:00:00.000 --> 00:00:03.060 >> So here we are in SPSS. 00:00:03.060 --> 00:00:04.900 I have created a junk data 00:00:04.900 --> 00:00:07.220 set just to help illustrate how we can 00:00:07.220 --> 00:00:08.840 compute variables or compute 00:00:08.840 --> 00:00:09.980 new variables using 00:00:09.980 --> 00:00:12.010 the values from existing ones. 00:00:12.010 --> 00:00:14.140 This is a pretty straightforward process. 00:00:14.140 --> 00:00:15.280 It looks a little bit 00:00:15.280 --> 00:00:16.680 different than things that we've done 00:00:16.680 --> 00:00:18.580 before or other ways that we're 00:00:18.580 --> 00:00:20.640 going to be using SPSS in this course. 00:00:20.640 --> 00:00:22.440 So it might look a little bit different, 00:00:22.440 --> 00:00:23.980 but it is pretty straightforward and 00:00:23.980 --> 00:00:26.375 pretty easy once you know how to do this. 00:00:26.375 --> 00:00:27.740 So the first thing that we'll 00:00:27.740 --> 00:00:29.345 do is go to Transform, 00:00:29.345 --> 00:00:30.680 and then the first option we 00:00:30.680 --> 00:00:32.120 have there is compute variable. 00:00:32.120 --> 00:00:34.440 So click on that. We get 00:00:34.440 --> 00:00:36.165 this new window that pops up. 00:00:36.165 --> 00:00:37.800 The first thing that we really want 00:00:37.800 --> 00:00:39.340 to look at is in the top left, 00:00:39.340 --> 00:00:42.580 and that's this target variable window. 00:00:42.580 --> 00:00:44.130 Basically what the computer 00:00:44.130 --> 00:00:45.610 is asking you is to create 00:00:45.610 --> 00:00:47.630 a name for the new variable 00:00:47.630 --> 00:00:49.070 that you're going to be computing. 00:00:49.070 --> 00:00:50.860 This name needs to be unique, 00:00:50.860 --> 00:00:53.170 it's one that can't have spaces in it, 00:00:53.170 --> 00:00:55.315 and it should avoid special characters. 00:00:55.315 --> 00:00:56.710 But, in this case, 00:00:56.710 --> 00:00:58.630 what I like to do is include 00:00:58.630 --> 00:01:01.330 some piece of information in there 00:01:01.330 --> 00:01:03.550 in the naming convention I use that 00:01:03.550 --> 00:01:04.810 helps me know what this is 00:01:04.810 --> 00:01:06.250 just by looking at it. 00:01:06.250 --> 00:01:07.890 So what we're going to be doing is 00:01:07.890 --> 00:01:09.650 we're going to be summing items 1, 00:01:09.650 --> 00:01:10.970 2, 3, 4, 5, 00:01:10.970 --> 00:01:12.740 and 6 together, adding those together. 00:01:12.740 --> 00:01:14.330 So an easy way to do that is 00:01:14.330 --> 00:01:17.480 just to put sumofitems. 00:01:17.480 --> 00:01:20.040 That way, when I look at 00:01:20.040 --> 00:01:21.850 this new variable once it's generated, 00:01:21.850 --> 00:01:23.350 I know that that's the variable 00:01:23.350 --> 00:01:24.930 that I really want to be working 00:01:24.930 --> 00:01:26.720 with or running my tests on 00:01:26.720 --> 00:01:28.030 because that contains 00:01:28.030 --> 00:01:29.865 the information from the other ones. 00:01:29.865 --> 00:01:32.970 You can click on Type & Label. 00:01:32.970 --> 00:01:36.390 The label is the more drawn-out explanation. 00:01:36.390 --> 00:01:37.870 That's one that you can include 00:01:37.870 --> 00:01:39.390 additional characters or 00:01:39.390 --> 00:01:41.070 spaces and special characters. 00:01:41.070 --> 00:01:43.150 In our case, I'm going to put this is 00:01:43.150 --> 00:01:48.975 the sum of items 1 through 6. 00:01:48.975 --> 00:01:50.790 And that way I know that 00:01:50.790 --> 00:01:52.550 that is going to give me 00:01:52.550 --> 00:01:55.150 a more drawn-out explanation 00:01:55.150 --> 00:01:57.010 of what this variable includes. 00:01:57.010 --> 00:01:59.325 We know this is going to be numeric. 00:01:59.325 --> 00:02:01.175 So click Continue. 00:02:01.175 --> 00:02:03.110 The next thing we're going to look at 00:02:03.110 --> 00:02:05.045 is this numeric expression box. 00:02:05.045 --> 00:02:06.530 And will actually come back 00:02:06.530 --> 00:02:07.730 to this in just a minute, 00:02:07.730 --> 00:02:08.390 but this is where you're 00:02:08.390 --> 00:02:09.330 going to be doing most 00:02:09.330 --> 00:02:11.390 of the work when you're computing a variable. 00:02:11.390 --> 00:02:13.190 What you'll want to go to next 00:02:13.190 --> 00:02:14.880 is this function group area. 00:02:14.880 --> 00:02:16.665 So I'm going to click on All. 00:02:16.665 --> 00:02:18.630 And you notice right below it we've 00:02:18.630 --> 00:02:20.580 got these functions and special variables, 00:02:20.580 --> 00:02:22.815 and this popped up when I clicked on All. 00:02:22.815 --> 00:02:24.550 This has a whole bunch of 00:02:24.550 --> 00:02:26.200 different pre-existing functions, 00:02:26.200 --> 00:02:27.640 so you don't need to reinvent the wheel, 00:02:27.640 --> 00:02:28.870 you can basically use 00:02:28.870 --> 00:02:30.950 these pre-existing functions to 00:02:30.950 --> 00:02:33.135 help you compute this new variable. 00:02:33.135 --> 00:02:34.710 I'm going to go down to sum, 00:02:34.710 --> 00:02:36.250 and these are in alphabetical order, 00:02:36.250 --> 00:02:37.890 so it's pretty easy to find. 00:02:37.890 --> 00:02:40.180 Here we have sum, and when I click on sum, 00:02:40.180 --> 00:02:41.490 you'll notice that this box on 00:02:41.490 --> 00:02:43.955 the left populated with some text. 00:02:43.955 --> 00:02:46.005 This box is actually pretty useful. 00:02:46.005 --> 00:02:47.650 So the first thing it shows you is 00:02:47.650 --> 00:02:48.570 an example of what 00:02:48.570 --> 00:02:50.210 this expression is going to be. 00:02:50.210 --> 00:02:51.540 And our expression sounds like 00:02:51.540 --> 00:02:52.635 a really fancy term. 00:02:52.635 --> 00:02:54.050 If you've ever used a formula 00:02:54.050 --> 00:02:55.670 in Excel, it's basically that. 00:02:55.670 --> 00:02:56.990 It's telling the computer 00:02:56.990 --> 00:02:58.465 what it needs to do. 00:02:58.465 --> 00:03:00.750 In this case, just like Excel, 00:03:00.750 --> 00:03:02.030 we've got the word sum, 00:03:02.030 --> 00:03:03.570 which tells the computer it's going to be 00:03:03.570 --> 00:03:05.365 summing different values together, 00:03:05.365 --> 00:03:06.630 and then in parentheses, 00:03:06.630 --> 00:03:07.570 immediately after that, 00:03:07.570 --> 00:03:09.070 we have different variables 00:03:09.070 --> 00:03:10.705 that are separated by a comma, 00:03:10.705 --> 00:03:11.930 and that's what tells the 00:03:11.930 --> 00:03:13.390 computer to add x, y, 00:03:13.390 --> 00:03:15.150 and z things together to create 00:03:15.150 --> 00:03:17.800 a new variable or compute a new variable. 00:03:17.800 --> 00:03:18.870 This also provides 00:03:18.870 --> 00:03:20.750 additional extra content here, 00:03:20.750 --> 00:03:22.190 but we don't need to worry about that. 00:03:22.190 --> 00:03:23.930 I found this is helpful if you 00:03:23.930 --> 00:03:26.000 are stuck or something isn't working right. 00:03:26.000 --> 00:03:27.930 So we've got sum selected, 00:03:27.930 --> 00:03:29.780 we're going to be summing the items of 1, 00:03:29.780 --> 00:03:31.760 2, 3, 4, 5, and 6 together. 00:03:31.760 --> 00:03:33.055 We've got that selected. 00:03:33.055 --> 00:03:34.110 So the next thing you do 00:03:34.110 --> 00:03:35.190 is click this up arrow, 00:03:35.190 --> 00:03:36.270 which basically takes 00:03:36.270 --> 00:03:38.030 that pre-existing function 00:03:38.030 --> 00:03:39.720 and it kicks it up to this numeric 00:03:39.720 --> 00:03:41.550 and expression box. 00:03:41.550 --> 00:03:43.870 The next thing that we're going to do, 00:03:43.870 --> 00:03:44.710 we've already told 00:03:44.710 --> 00:03:45.810 the computer that we're going 00:03:45.810 --> 00:03:47.740 to sum different variables together, 00:03:47.740 --> 00:03:48.910 we need to tell it which 00:03:48.910 --> 00:03:50.480 variables to sum together. 00:03:50.480 --> 00:03:52.790 So the easy way to do this is to 00:03:52.790 --> 00:03:54.110 click on the first 00:03:54.110 --> 00:03:55.445 item that you want to include, 00:03:55.445 --> 00:03:57.850 and you'll notice that this arrow 00:03:57.850 --> 00:03:59.290 switch sides from pointing 00:03:59.290 --> 00:04:00.785 to the left to pointing to the right, 00:04:00.785 --> 00:04:02.060 click over 1, 00:04:02.060 --> 00:04:04.350 and we've already moved over item 1. 00:04:04.350 --> 00:04:07.020 What you need to be careful of is that you 00:04:07.020 --> 00:04:09.640 always have a comma after each variable, 00:04:09.640 --> 00:04:11.085 except for the last one. 00:04:11.085 --> 00:04:12.600 So a comma is already here, 00:04:12.600 --> 00:04:14.815 but what I usually do is I just hit a comma, 00:04:14.815 --> 00:04:16.675 I go to item 2, 00:04:16.675 --> 00:04:19.010 kick that over, comma, 00:04:19.010 --> 00:04:21.030 item 3, kick that over, 00:04:21.030 --> 00:04:23.550 comma, item 4, kick that over, 00:04:23.550 --> 00:04:25.260 comma, item 5, 00:04:25.260 --> 00:04:26.880 kick that over, comma, 00:04:26.880 --> 00:04:28.935 item 6, kick that over. 00:04:28.935 --> 00:04:30.420 Now, we know that item 6 00:04:30.420 --> 00:04:31.920 is the last one we have, 00:04:31.920 --> 00:04:33.690 the last variable we're including, 00:04:33.690 --> 00:04:35.100 so what we're going to do is 00:04:35.100 --> 00:04:36.700 just delete out that question mark, 00:04:36.700 --> 00:04:38.515 we're going to delete out that last comma, 00:04:38.515 --> 00:04:40.260 and then if we read through this real quick 00:04:40.260 --> 00:04:40.980 just to make sure we 00:04:40.980 --> 00:04:42.190 don't have any problems, 00:04:42.190 --> 00:04:45.095 we've got creating sumofitems, 00:04:45.095 --> 00:04:46.880 this is going to be the sum of 00:04:46.880 --> 00:04:48.435 item 1, 2, 3, 00:04:48.435 --> 00:04:51.280 4, 5, and 6, 00:04:51.280 --> 00:04:54.095 and what we're going to do now is click OK. 00:04:54.095 --> 00:04:56.620 An output window pops 00:04:56.620 --> 00:04:57.720 up and it basically tells 00:04:57.720 --> 00:04:58.860 you what the computer did. 00:04:58.860 --> 00:05:00.500 It computed the sum of items, 00:05:00.500 --> 00:05:01.830 which was the sum of item 1, 00:05:01.830 --> 00:05:03.315 2, 3, 4, 5, and 6, 00:05:03.315 --> 00:05:05.110 it gives us the variable label, 00:05:05.110 --> 00:05:08.620 it gives us that descriptive text I put in. 00:05:08.620 --> 00:05:10.080 I'm just going to minimize this window, 00:05:10.080 --> 00:05:11.280 and if we look back here, 00:05:11.280 --> 00:05:12.200 you might notice that 00:05:12.200 --> 00:05:13.620 there's this new column, 00:05:13.620 --> 00:05:15.510 this new variable, that sumofitems, 00:05:15.510 --> 00:05:16.935 that wasn't there when we started, 00:05:16.935 --> 00:05:19.155 and that's because SPSS computed that. 00:05:19.155 --> 00:05:20.780 And if we add these together, 00:05:20.780 --> 00:05:22.235 if you add each row, 00:05:22.235 --> 00:05:24.320 we've got 1, 2, 1, 3, 5, 00:05:24.320 --> 00:05:26.565 1, that adds to 13, 00:05:26.565 --> 00:05:28.005 5, 1, 2, 00:05:28.005 --> 00:05:29.940 3, 5, 1 adds to 17. 00:05:29.940 --> 00:05:31.540 So it's done that math for us. 00:05:31.540 --> 00:05:33.425 We didn't have to manually do it. 00:05:33.425 --> 00:05:35.720 I know, yes, it'd be pretty easy to 00:05:35.720 --> 00:05:38.280 manually do this for 10 cases, 00:05:38.280 --> 00:05:41.060 but if you have a dataset that has 500 cases, 00:05:41.060 --> 00:05:43.000 that would be very time-consuming to do. 00:05:43.000 --> 00:05:45.460 And you could see that this function of 00:05:45.460 --> 00:05:47.360 computing this variable can 00:05:47.360 --> 00:05:48.460 save you a lot of time. 00:05:48.460 --> 00:05:49.820 It's also more accurate. 00:05:49.820 --> 00:05:51.385 It's going to take any error 00:05:51.385 --> 00:05:53.790 out of the equation. 00:05:53.790 --> 00:05:54.940 And we know that often 00:05:54.940 --> 00:05:56.120 when we do things by hand, 00:05:56.120 --> 00:05:57.900 we can introduce error into things, 00:05:57.900 --> 00:05:59.550 so we want to avoid that. 00:05:59.550 --> 00:06:01.845 That's one way to computer a variable. 00:06:01.845 --> 00:06:04.760 I'm going to show you a different type 00:06:04.760 --> 00:06:06.160 of variable that we can compute. 00:06:06.160 --> 00:06:07.845 I'm going to go back to Transform, 00:06:07.845 --> 00:06:09.570 I'm going to go back to Compute Variable. 00:06:09.570 --> 00:06:11.420 I'm actually going to clear this out. 00:06:11.420 --> 00:06:12.860 We're done with someofitems, 00:06:12.860 --> 00:06:13.840 we don't need to worry about it, 00:06:13.840 --> 00:06:15.280 we're not going to use the same expression, 00:06:15.280 --> 00:06:16.140 so I'm going to click 00:06:16.140 --> 00:06:17.835 Reset in the bottom here. 00:06:17.835 --> 00:06:20.240 So what I want to do is create 00:06:20.240 --> 00:06:22.540 the mean of the different items that we have. 00:06:22.540 --> 00:06:24.000 Sometimes if you're working 00:06:24.000 --> 00:06:26.100 with a pre-existing scale, 00:06:26.100 --> 00:06:28.320 it might tell you to add 00:06:28.320 --> 00:06:29.740 all the items together and then 00:06:29.740 --> 00:06:31.340 that's what represents 00:06:31.340 --> 00:06:34.225 that theoretical concept or that measure, 00:06:34.225 --> 00:06:36.380 sometimes it might tell you to use the mean. 00:06:36.380 --> 00:06:38.600 So what I want to do is compute both of 00:06:38.600 --> 00:06:39.720 these things because they 00:06:39.720 --> 00:06:41.295 both might be helpful to me. 00:06:41.295 --> 00:06:42.860 So what I'm going to do is 00:06:42.860 --> 00:06:44.990 I'm going to type meanofitems. 00:06:44.990 --> 00:06:47.240 And again, that very quickly lets me 00:06:47.240 --> 00:06:48.230 differentiate between 00:06:48.230 --> 00:06:49.970 sumofitems and meanofitems. 00:06:49.970 --> 00:06:51.700 Type & label, and again, 00:06:51.700 --> 00:06:54.720 I'm just going to put mean of items 1 through 00:06:54.720 --> 00:07:01.905 6, click Continue. 00:07:01.905 --> 00:07:04.900 Just like we did before, click on All, 00:07:04.900 --> 00:07:06.380 and then we're going to go down 00:07:06.380 --> 00:07:10.335 to mean, here's mean. 00:07:10.335 --> 00:07:11.790 And when I click on that, again, 00:07:11.790 --> 00:07:14.090 it gives me that sample text here. 00:07:14.090 --> 00:07:16.975 This is very similar to what we did before. 00:07:16.975 --> 00:07:19.330 I'm going to click up, and 00:07:19.330 --> 00:07:21.505 we're going to kick over 1, 00:07:21.505 --> 00:07:29.610 2, 3, 4, 5, and then 6. 00:07:29.610 --> 00:07:31.070 I'm making sure to not 00:07:31.070 --> 00:07:33.835 include this last one, this sumofitems. 00:07:33.835 --> 00:07:35.250 And then just like last time, 00:07:35.250 --> 00:07:36.150 we're going to delete out 00:07:36.150 --> 00:07:37.280 that question mark, that last comma. 00:07:37.280 --> 00:07:38.790 We're going to read through 00:07:38.790 --> 00:07:40.505 it really quickly just to avoid an error. 00:07:40.505 --> 00:07:42.820 We've got a new variable, meanofitems. 00:07:42.820 --> 00:07:44.835 It's going to be the mean of item 1, 00:07:44.835 --> 00:07:47.265 2, 3, 4, 5, and 6. 00:07:47.265 --> 00:07:51.130 I'm going to click OK. SPSS 00:07:51.130 --> 00:07:53.895 again showed me the syntax of what it did. 00:07:53.895 --> 00:07:55.695 I'm going to minimize that. 00:07:55.695 --> 00:07:58.080 And then here we have the mean of items. 00:07:58.080 --> 00:08:00.010 And if we really quickly look at this, 00:08:00.010 --> 00:08:01.990 I'm going to pick this one, for example, 00:08:01.990 --> 00:08:03.700 we've got 1, 00:08:03.700 --> 00:08:06.110 1, 3, 3, 1, 2, 00:08:06.110 --> 00:08:07.710 and a mean of 1.83 would, 00:08:07.710 --> 00:08:09.975 just eyeballing it, make sense. 00:08:09.975 --> 00:08:11.580 If we look at this one, 00:08:11.580 --> 00:08:13.590 3.67, 2, 00:08:13.590 --> 00:08:15.645 3, 5, 4, 5, 3, 00:08:15.645 --> 00:08:16.990 that would roughly make sense 00:08:16.990 --> 00:08:18.650 without having to do the math of it, 00:08:18.650 --> 00:08:21.310 but this has computed the average score, 00:08:21.310 --> 00:08:24.450 the mean score for all six of those items. 00:08:24.450 --> 00:08:26.590 So that is very quickly how to 00:08:26.590 --> 00:08:28.810 compute a new variable in SPSS. 00:08:28.810 --> 00:08:30.410 This is particularly useful 00:08:30.410 --> 00:08:32.190 when you have collected data using 00:08:32.190 --> 00:08:34.610 a pre-existing measure and that measure has 00:08:34.610 --> 00:08:36.310 instructed you to compute 00:08:36.310 --> 00:08:38.510 the sum of items and run your tests on that, 00:08:38.510 --> 00:08:39.930 or maybe the mean of items 00:08:39.930 --> 00:08:41.450 and run your tests on that. 00:08:41.450 --> 00:08:43.130 But this is a useful way 00:08:43.130 --> 00:08:44.450 of understanding how to create 00:08:44.450 --> 00:08:48.190 new variables using existing ones in SPSS.