UCLA Processing Data Iteratively & Restructuring a Data Set Programming Exercise
Question Description
There are 3 parts , using SAS to produce the answer , save as three files, one program file, one output file, and one log file for the entire assignment.
see attached file for more questions.
1. Using an Iterative DO Statement with a Conditional Clause
Orion’s income last year was $50,000,000 and expenses totaled $38,750,000. Income is projected
to increase at 1% per year and expenses are expected to increase at 2% per year.
a. Create a SAS data set named work.expenses that contains each year’s projected income
and expenses.
Use an iterative DO statement with a conditional clause.
Stop the loop when expenses exceed income or after 30 years, whichever comes first.
b. Print the results and format Income and Expenses with a dollar sign and two decimal places.
Hint: Recall that an iterative DO statement with a conditional clause produces different results with DO WHILE and DO UNTIL statements. The results below were generated using a DO UNTIL statement.
PROC PRINT Output
Obs Income Expenses Year
1 $64,762,815.75 $64,844,951.93 26
2. Using Arrays for Repetitive Computations
Monthly customer order data for the first half of the year is stored in the data set orion.orders_midyear. Orion Star Sales management is considering a 10% price decrease during the first three months of the upcoming year. Management wants to see how such a discount would affect this year’s sales.
Partial orion.orders_midyear
Customer_ID Month1 Month2 Month3 Month4 Month5 Month6
5 213.10 . 478.0 525.80 394.35 191.79
10 188.10 414.09 2876.9 3164.59 2373.44 169.29
11 78.20 . . . . 70.38
12 135.60 . 117.6 129.36 97.02 122.04
18 . . 29.4 32.34 24.26 .
a. Create a data set, special_offer, including the 10% discount in months 1 through 3.
Create an array, Mon, to access Month1 through Month3.
Use a DO loop to adjust each customer’s monthly data to include the 10% discount (Month1 through Month3 only).
Create three new variables:
–Total_Sales – the total of current sales over the six months
–Projected_Sales – the total of the adjusted sales over the six months (including the
three discounted months)
–Difference – the difference between Total_Sales and Projected_Sales
Keep only the new variables: Total_Sales, Projected_Sales, and Difference.
b. Print the resulting data set and verify your results.
Suppress the session start date, page number, and observation column.
Add an appropriate title.
Use the SUM statement to display a total for the Difference variable.
Use the DOLLAR. format for all variables.
Partial PROC PRINT Output (24 Total Observations)
Total Sales with 10% Discount in First Three Months
Total_ Projected_
Sales Sales Difference
$1,803.04 $1,733.93 $69.11
$9,186.41 $8,838.50 $347.91
$148.58 $140.76 $7.82
$601.62 $576.30 $25.32
…
$1,518.95 $1,467.02 $51.93
==========
$1,550.74
Have a similar assignment? "Place an order for your assignment and have exceptional work written by our team of experts, guaranteeing you A results."