Exercise 1 Merge Files: Fieldname Fieldtype
Exercise 1 Merge Files: Fieldname Fieldtype
Merge Files
1. Create a blank dataset called MonthlySales.sav with the following structure
FieldName
Month
CategoryID
Item1
Item1Sales
Item2
Item2Sales
2.
3.
4.
5.
FieldType
Date
String
String
Numeric
String
Numeric
14. Next we need to include the category in the monthly sales based on the
CategoryID field
15. Close both JanSales.sav and FebSales.sav
16. Open CategoryMaster.sav
17. Sort CategoryMaster.sav on CategoryID
18. Make MonthlySales.sav the active dataset.
19. Sort MonthlySales.sav on CategoryID
20. Select Data -> Merge Files -> Add Variables
21. Select CategoryMaster.sav from the list and click Continue
22. In the next dialog box, you will see that SPSS has automatically selected all
unique variables along with common variable (CategoryID) from MonthlySales.
23. Do the selections as per the following screen:
24. Click OK
25. You will get a warning about the sorting. Click OK
26. You now have your MonthlySales.sav dataset with the category included
27. Close the CategoryMaster.sav
Restructure Data
1. Make sure that MonthlySales.sav is the active dataset
4. Select More than one in the next dialog box and input 2 in the text box and
click Next
5. In the next screen move select Month, CategoryID and Category and move
them to the Fixed Variables list.
6. Select the Target Variable dropdown and rename trans1 to Item
7. Then select Item1 and Item2 and move them to the Target Variable list
under Item
8. Next select trans2 and rename it to Sales
9. Then select Item1Sales and Item2Sales and move them to the Target
Variable list under Sales
10. You should now have the screen similar to below:
Lets now create a dataset that contains monthly sales by month and category
Make MonthlySales.sav the active dataset.
Select Data -> Aggregate
Move Month and Category to the Break variables list
Move Sales to the Summaries of variables list
6. Since we want to have sum of sales by month and category, click on the
Function button and select Sum from the various statistics and click
Continue
7. Select Create a new dataset containing only aggregated variables and type
SalesSummary in the dataset name field
8. Select Sort file before aggregating. Your screen should look like this:
9. Click OK
10. You now have a new dataset with only the sales summary