0% found this document useful (0 votes)
100 views

Exercise 1 Merge Files: Fieldname Fieldtype

The document provides instructions to merge sales data from multiple files into a single file called MonthlySales.sav, restructure the data from wide to long format with items and sales as separate records, and then aggregate the data to create a summary file with total monthly sales by category. The steps have the user open original sales files from January and February, copy the data into the MonthlySales file, merge in category descriptions, restructure the data, and then aggregate it to create a new SalesSummary file with total monthly sales by category.

Uploaded by

Revati
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
100 views

Exercise 1 Merge Files: Fieldname Fieldtype

The document provides instructions to merge sales data from multiple files into a single file called MonthlySales.sav, restructure the data from wide to long format with items and sales as separate records, and then aggregate the data to create a summary file with total monthly sales by category. The steps have the user open original sales files from January and February, copy the data into the MonthlySales file, merge in category descriptions, restructure the data, and then aggregate it to create a new SalesSummary file with total monthly sales by category.

Uploaded by

Revati
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 6

Exercise 1

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

Open the files JanSales.sav, FebSales.sav in SPSS Statistics.


Select the MonthlySales.sav as the active dataset
Select Data -> Merge Files -> Add Cases
Select JanSales.sav from the dialog and click Continue

6. Click OK in the next dialog box.


7. You can see that all the data from JanSales.sav has been copied to
MonthlySales.sav
8. Make MonthlySales.sav the active file again.
9. Select Data -> Merge Files -> Add Cases
10. Select FebSales.sav from the dialog and click Continue
11. Click OK in the next dialog box.
12. You can see that all the data from FebSales.sav has been copied to
MonthlySales.sav
13. So now you have MonthlySales.sav that contains data for both months.

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

2. Select Data -> Resturcture


3. Select Restructure selected variables into cases and click Next

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:

11. Click Next


12. In the next screen select None and click Next
13. In the next screen click Next
14. Click Finish on the next screen.
15. Click OK in the next dialog.
16. Your file is now restructured!!
Aggregate
1.
2.
3.
4.
5.

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

You might also like