Task [4-4]
The data set ONLINE_RETAIL contains all online sales data for all countries, up to and including September 2011.
Now that you know each country could submit their data to you differently, you would like to create a macro to reduce the amount of code required each time you add data to the ONLINE_RETAIL data set.
Now that you know each country could submit their data to you differently, you would like to create a macro to reduce the amount of code required each time you add data to the ONLINE_RETAIL data set.
france_sales_201111.sas7bdat |
france_sales_201112.sas7bdat |
germany_sales_201111.sas7bdat |
germany_sales_201112.sas7bdat |
First, create a new dataset ONLINE_RETAIL_MASTER which is a copy of ONLINE_RETAIL.
Next, using the code for Task 2 and Task 3, create a macro which will append the monthly sales data from different countries to ONLINE_RETAIL_MASTER.
The macro should have the following features:
- Two parameters:
(a) Data: to specify the dataset name to be added to ONLINE_RETAIL
(b) Country: to specify the country where the dataset originated from. - Depending on the country specified, the macro should conditionally execute either the code from Task 2 (if France was specified for country) or the code from Task 3 (if Germany was specified for the country).
- After each run, use a %put statement to output the number of records to the log found in ONLINE_RETAIL_MASTER, both before running the load macro and after running the load macro.
- Use your macro to load the French and German sales data for October, November and December 2011, like this:
%load(data=a.france_sales_201110,country=France);
%load(data=a.france_sales_201111,country=France);
%load(data=a.france_sales_201112,country=France);
%load(data=a.germany_sales_201110,country=Germany);
%load(data=a.germany_sales_201111,country=Germany);
%load(data=a.germany_sales_201112,country=Germany);
Tip: PROC APPEND can be used within the macro to ensure that the data sets are being added to ONLINE_RETAIL with each run of the macro.