Question: 3 . Using an Iterative and Conditional DO Loop in SAS ( My answers are in the SAS coding below, which I want to confirm

3. Using an Iterative and Conditional DO Loop in SAS (My answers are in the SAS coding below, which I want to confirm are correct or input to help correct my answers, thank you!)
The pg2.eu_sports table contains European Union trade amounts for sport products. Belgium wants to see their exports exceed their imports for golf and racket products. They expect to annually increase exports by 7% and want to achieve their goal within 10 years.
a. Open p206p05.sas from the practices folder. Run the program and review the results. Notice that the golf export number is farther from the golf import number as compared to the racket export and import numbers.
b. Add a conditional DO loop around the assignment statement for Amt_Export.
i. Use a DO WHILE statement that executes while the export value is less than or equal to the import value.
ii. Create a Year column that increments by a value of 1.
iii. Create a row of output for each year.
data pg2.eu_sports;
set pg2.eu_sports;
Year =2016;
do while (Amt_Export <= Amt_Import);
output;
Amt_Export = Amt_Export *1.07;
Year +1;
end;
run;
c. Run the program and review the results.
Partial Results (5 of 18 Rows)
d. How many years did it take until the exports exceeded the imports, and what is the final Year value for each sport product? 2015
proc sql;
select Sport_Product, max(Year) as Final_Year, count(*) as Number_of_Years
from pg2.eu_sports
group by Sport_Product;
quit;
Sport_Product Number of Years Final Year
GOLF
RACKET
e. Modify the DO statement to include an iterative portion before the conditional portion. The iterative portion needs to be based on Year values of 2016 to 2025(10 years).
data pg2.eu_sports;
set pg2.eu_sports;
do Year =2016 to 2025;
do while (Amt_Export <= Amt_Import);
output;
Amt_Export = Amt_Export *1.07;
end;
end;
run;
f. Within the DO loop, delete any statements related to the incrementing of Year.
g. Run the program and review the results. The results show 14 data rows.
h. Complete this table based on your last modification:
proc sql;
select Sport_Product, max(Year) as Final_Year, count(*) as Number_of_Years,
case when Amt_Export > Amt_Import then 'Yes' else 'No' end as Do_Exports_exceed_Imports
from pg2.eu_sports
group by Sport_Product;
quit;
Sport_Product Number of Years Final Year Do Exports exceed Imports?
GOLF
RACKET
i. Delete the OUTPUT statement.
j. Run the program and review the results.
k. Do these Year values equal the final Year values before deleting the OUTPUT statement? Why or why not?
l.(Optional) Include a conditional OUTPUT statement within the DO loop that will show the two rows of output with the Year values equal to the final Year values before deleting the OUTPUT statement.
data pg2.eu_sports;
set pg2.eu_sports;
do Year =2016 to 2025;
do while (Amt_Export <= Amt_Import);
if Year =2025 then output;
Amt_Export = Amt_Export *1.07;
end;
end;
run;

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!