STAT 541 Homework 5 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 CTL2015more data set has data for the players in CTL2015 who played at least one match in the singles league in 2015. It has 4 additional variables: MatchWins, MatchLosses, GameWins, and GameLosses. The data can be read in using this code (note Rating is read as a NUMERIC variable here): DATA CTL2015more; FILENAME webpage3 URL 'http://people.stat.sc.edu/hitchcock/tennissinglesmore.txt'; INFILE webpage3 DLM='09'X; INPUT Name :$24. Gender $ City :$10. State $ Rating RatingDate MMDDYY10. RatingType $ MatchWins MatchLosses GameWins GameLosses; run; (a) Write a program that first creates an additional variable called GameWinPct, where GameWinPct= 100*(GameWins/(GameWins+GameLosses)) and also an additional variable called MatchWinPct, where MatchWinPct= 100*(MatchWins/(MatchWins+MatchLosses)). (b) The Rating values in this data set are 2.5, 3.0, 3.5, 4.0, 4.5 (suppose that 2.0 and 5.0 are also possible Ratings). Suppose that if a player has 0 or 1 match wins in 2015, he will decrease a rating level for the next year (i.e., his Rating will decrease by 0.5). If a player has 2, 3, 4, or 5 match wins, his Rating will remain the same for the next year. If a player has 6 or 7 match wins, he will increase a rating level for the next year (i.e., his Rating will increase by 0.5). Create a lookup table in the form of an array that will take a player's current Rating and his number of match wins and properly output his rating level for the next year (call this Rating2016). Apply this lookup table to the CTL2015more data set and print out variables: Name, Rating, MatchWins, Rating2016. (c) Using the PICTURE statement in PROC FORMAT, create a custom format that will print out the Rating to two decimal places along with a message, so that 4.5 is formatted as 4.50 Top Player for example. The other rating levels should be printed out similarly, except that the message for 2.5 should be Beginner, for 3.0 should be Learning Player, for 3.5 should be Intermediate Player, and for 4.0 should be Skilled Player. Print out the data set so that the format can be seen. (d) Using the PICTURE statement in PROC FORMAT, create a custom format that will print out the MatchWinPct (as a percentage, i.e., between 0 and 100) to two decimal places, with a percent symbol following, along with a message, so players with a MatchWinPct above 50% have the message Successful Player while other players have the message Less Successful Player Print out the data set so that the format can be seen. (e) Using the PICTURE statement in PROC FORMAT, create a custom format that will print out RatingDate with a full month name, day of the month as 1-31 with no leading zero, and the year (with the century) as a number. Print out the data set so that the format can be seen. HINT: You can add trailing blanks to your directive to increase the maximum length of the formatted date value.