STAT 541 Homework 3 NOTE: You MUST intersperse comments (lines that start with * and end with ; or lines that start with /* and end with */) in your code to explain what your SAS statements are supposed to be doing. Please be generous with your comments, since you will be graded not only on the correctness of the code, but partially on the clarity of comments. NOTE: Submit your solution code via Blackboard (see course web page for instructions). Please save your work as a plain text file (e.g., a .txt file) and then submit that file in Blackboard. NOTE: PLEASE put WITHIN COMMENTS any text (i.e., if you choose to include problem numbers, problem description, your personal comments, output/results) in your file that is not actual SAS code. This will make it easier and faster to grade. The grader should be able to copy and paste your entire file into SAS and have it run correctly. 1. The following problem will use the sashelp.baseball data set. (a) Use a %LET statement to create a macro variable that will represent a particular player Name, so that the user can specify any player Name and retrieve the statistics for the player(s) with that name. NOTE: It should also work if the user specifies part of a name. Use this macro variable in a short program to print the statistics for any player whose name contains the character string "Don". Have the program also put a descriptive title on the output that includes the chosen value of the macro variable. [ALSO: What happens if in part (a), you let the chosen character string be "don"?] (b) Write a SAS macro called descripstat that will calculate a descriptive statistic for a variable, in an arbitrary SAS data set. The statistic, the variable, and the name of the data set should be macro parameters. The descriptive statistic should be one that can be calculated by PROC MEANS. Have the macro include a title on the output that describes exactly what is being calculated. [Hint: You may want to look at the PROC MEANS help files in the online SAS help documentation.] (c) Invoke the macro in such a way that it will calculate the mean number of hits (nHits) for the players in the sashelp.baseball data set. Then invoke the macro in such a way that it will calculate the total (summed) number of home runs (nHome) for the players in the sashelp.baseball data set. (d) Write a macro that will calculate the mean for an arbitrary number of numeric variables (where the set of variables is provided by the user), for the sashelp.baseball data set. The numeric variable(s) should be SEPARATE macro parameters (i.e., separated by commas when the macro is invoked). (e) Write the macro so that it will print the top few highest-ranking players in the sashelp.baseball data, of a certain position, in a certain league, based on a certain baseball statistic. [Highest-ranking here means having the largest values of the baseball statistic.] The number of players printed, the baseball statistic, the position, and the league should be macro parameters. NOTE: Please use PROC SQL tools to accomplish this, rather than simply using PROC SORT, PROC PRINT and other basic procedures that we learned in STAT 540! (f) Invoke the macro in (e) to print the top 4 first basemen ("1B") in the American league based on their number of runs batted in (nRBI). (g) Use an %IF-%THEN-%ELSE construction to perform any conditional operation of your choosing within a macro that works with the sashelp.baseball data set. Be sure to use comments to carefully explain what the conditional operation does.