*Total 90 pts for this workshop;
*Q1 – follow the class example, create a simulation data using DO loops. Suppose it’s a sales
and taxes tracking data for a pariticular small buisness.
** Q1.1: Use a DATA step and a DO loop to create a dataset that matches with the following
descriptions: the data has 12 observations, including a Month variable ranging
from 1-12 (10pts), a Sales variable with random values ranging from 3000-5000 (see hint
below for the random values) (10pts), and a Tax variable that is 5% of Sales amount plus
a constant 300 as the base tax (5pts).
Hint: check the RANUNI funtion that generates random data from 0 to 1. In this question,
multiply the random number by 2000 then add a constant 3000.;
** Q1.2: The owner wants to see how much tax was paid over time. Use the data set you created in
1.1 and add a variable to calculate the cumulative taxes (10pts). Format your variables
Sales, Tax and Cumulative Tax to start with a dollar sign, separated by comma, and keep
two decimal places. (5pts);
** Q1.3: Use a different method to create the same varaible in Q1.2 (5pts);
*Q2 – Let’s modify the simulation requests in Q1 above and create a larger dataset that includes
several years of sales and tax data.
** Q2.1: Use a DATA step and DO loops to create a dataset that matches with the following
descriptions: the data has a variable Year ranging from 2004 to 2013 (10pts). In each year,
there are 12 observations representing the 12 months for the year, indicated by a Month
variable ranging from 1-12 (10pts). There should be 120 observations in total. The data
also includes a Sales and a Tax variable, using the same definition as in Q1 above (5pts each).
Hint: You will need to nest two DO loops in your codes, one for year and one for month;
** Q2.2: This time, the owner wants to see a year-to-date tax over time. It means that you need
to create a cumulative taxes variable that starts from each January, accumulate till the end
of the year, then reset your cumulative taxes to zero and restart in the following January
(10pts). Format your data similarly as in Q1.2 (5pts).
To verify your result, in each January the cumulative taxes should be the same as tax of the
Month. And in each December, the cumulative taxes should be the total taxes for the year.;