STAT 541 Homework 7 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. For this problem we will begin with the sashelp.baseball data set. (a) Create a character variable (in the usual default way) called PlayerType which equals 'Infielder' if Position is either 1B, 2B, 3B or SS; or else equals 'Outfielder' if Position is either LF, CF, RF or OF; or otherwise equals 'Other'. Print out the full data set, printing the Name and PlayerType variables. Comment on why the result is not ideal. (b) Repeat part (a), but when you create the PlayerType variable, use the LENGTH statement to correct the unfortunate results from part (a). Comment on the result. 2. For this problem we will begin with the sashelp.baseball data set. (a) Define a variable called BatAvg that equals nHits divided by nAtBat. Use PROC MEANS to calculate and print the mean batting average for the entire sashelp.baseball data set. (b) Now define a variable called BatAvg that equals nHits divided by nAtBat, but use the LENGTH function to specify that the length of BatAvg should be 3. Use PROC MEANS to calculate and print the mean of this "truncated" BatAvg variable for the entire sashelp.baseball data set. Comment on any differences between this result and that in part (a).