This document provides an analysis of basketball scoring in 2012 based on class and position. It includes average baskets per game for different score types and positions.
Contribute Materials
Your contribution can guide someone’s learning journey. Share your
documents today.
/*1.Begin your program with the required header, filename, and libnamestatements. As always, yourprogram must includecomments in the appropriate places. Use filename statements to definethe paths to the two raw data files. The readonly option doesnot apply to these two filename statements. */ /*Create a library name as MyLib and import hiscores.sas7bdat dataset*/ libnameMyLib '/folders/myfolders/Project-13-967790/'; datahiscores; setMyLib.hiscores; run; /*2.For this assignment the output file must be created with the pagesin a landscape layout. The dateisto only be displayed on the final section of the output. TheSASoutput portion ofyour PDFfile should start on page number 2. */ /*3.Create a user defined format that can be used to display the scoretype in the downloaded data setasshown in the Type column on the first page of the sample output.(In the data, PT is an abbreviation for Point and FT is short for Free Throw.) */ /*4.Use the tabulate procedure to produce the output shown in theposted results based on the hiscores data set. Use labels as needed. Apply your user defined formatto display the values of scoretype shown in the Type column. */ procformat; value $typefmt (multilabel)/*User defined format name as "typefmt" that can be used to display the score type */ '2PT' = "Two-Point" '3PT' = "Three-Point" 'FT'= "Free Throw"; run; optionsorientation=landscape; /*Output page in a landscape layout*/
Secure Best Marks with AI Grader
Need help grading? Try our AI Grader for instant feedback on your assignments.
optionsnodate pageno=2 number; /*The SAS output portion of your PDFfile should start on page number 2. */ title1'2012 Basketball Scoring Analysis'; title2'Baskets Made by Class and Position'; proctabulate data=hiscores; classclass position score_type; varbpg; tablescore_type = 'Type', class='Class' * bpg = 'Baskets per Game' * (Mean Median) position = 'Position' *bpg = 'Baskets per Game' * (Mean Median); format score_type $typefmt.; run; /*5.Write a data step similar to the one shown in the lectures thatconverts the USPres.csv file to a SASdataset named USPres in the work library. This data step will includeinfile, input, format, andlabel statements. Youwill need to make certain decisions aboutthis data (such as column widthsand the presentation of dates) based on your observations. Youwill need to use the firstobs option for the infile statement to tell SAS to skip the columntitles that are inthe raw data.Unlike the data step option by the same name, this option doesnot use parenthesis.The datesmust be presented in the WORDDATE format when the dataset isviewed or printed. . It isexpected that you willget the error shown below but you shouldnot have any othererrors or warnings in your log. a.Thecolumns must be inthe order shown in the printed output withoutusing any statements in the print procedure to control the order. b.Eventhough the current president is still serving, we wantan endofterm date so we candosome additional calculations. Add a line of code to this datastep that will set the endofterm date (Exited)to April 15, 2019 when the end of term dateismissing. c.Create a new variable that contains the number of years each president has been out of office.This calculation should be able to automatically adjust ifthecode is run again a yearfrom now. We will not be taking into account rounding or partialyears. This value
willbecalculated by simply subtracting the year of the presidents first term, byusing a conditional statement based on values in the data to restrict the observations printed. Use the appropriate enhancements to ensure that the labelbreaks as shown in the eCampus output.*/ /*Import a file USPres.csv and Use filename statements to definethe paths to the two raw data files.*/ optionsnodate pageno=3 number;/* starts with page number 3 withnodate */ title'U.S. Presidents Starting with Cleveland'; /* Title */ dataUSPres; retainPresidentParty Home_State Presidency Took_office Left_office Years; /*Set sequence of the columns */ infile'/folders/myfolders/Project-13- 967790/3332935_1560390127_USPres.csv' dlm=',' firstobs=2; /*import datase */ lengthPresidencyPresident $27. Took_officeLeft_officeParty $10.Home_State $13.; /*Set the lengths for the columns */ inputPresidencyPresident $ Took_officeLeft_office $ Party$ Home_State$; /*Set the input column names */ NewDatevar1= input(Took_office,anydtdte32.); NewDatevar2= input(Left_office,anydtdte32.); formatnewdatevar1 worddate19.NewDatevar2 worddate19.; /* Changedthe date format */ keepPresidentParty Home_State Presidency NewDatevar1 NewDatevar2 Years; /*Keeponly these variables as output variables */ ifNewDatevar2 = .thenNewDatevar2 = '15Apr2019'd; /* Changedthe missing valuewith the ‘April 15, 2019’ */ Years=intck('years', NewDatevar2, today()); /*Year counts from currentdates */ ifPresidency >= 22 then output; /*Select observations from president Cleveland */ labelNewDatevar1 = 'Start of Term'NewDatevar2 = 'End of Term' Presidency = '#'Home_State = 'Home State' Years= 'Years Out of Office'; /*Rename the variabels */ run; procprint data = USPres label noobs; /*Print the datasets */ varPresidentParty Home_State Presidency NewDatevar1 NewDatevar2 Years; run;
/*7.The 2012stats file contains the following variables: Rank, Name,Team, Class, Position, Number ofgames played (Games), Field Goals Made (FGM), Three-point FieldGoals Made (3FG), Free Throws(FT), Total Points(PTS), Average points per game (PPG), andConference (Conf). Use notepad, Word, or some other text editing program to open this fileand examine the dataand thefile layout. You willneed to make certain decisions about thisdata (such as columnwidths) basedon your observations. Write a data step that converts the csvfile to a SAS datasetin your worklibrary. Be sure to check the log very carefully when you readinthe raw data. Youshould notgetinvalid data errors when reading this data. If you do, thenyou most likely do not have yourdata step set up to read the raw data correctly. */ /*Import a file stats.csv and Use filename statements to definethe paths to the two raw data files.*/ filename MyLib '/folders/myfolders/Project-13- 967790/3332936_394450699_2012stats.csv'; procimport datafile=MyLib dbms=CSV out=stats; getnames=YES; run; /*8.Use the SUMMARY procedure to create an output data set that contains the average number of gamesplayed grouped by the values in the variable CLASS (FR, SO, etc.). 9.Print out the data portion of the summary data set. Make sure thedate is printed at the top of thepage for this output step. Use other enhancements to supply titlesand a footnote as shown.Suppress the printing of observation numbers. 10.Atthe end of your program include statements to ensure that titlesand footnotes do not get carried over to any subsequent output generated during this SASsession. 11.Review the output from steps 8 and 9 above. Before converting
Paraphrase This Document
Need a fresh take? Get an instant paraphrase of this document with our AI Paraphraser
yourprogram to PDF, write a twoorthree sentence paragraph in a comment block at the bottom ofyourprogram describing anyconclusions or observations that you have made from the summarydata set. 12.Convert the program and log to PDF files and submit them to eCampusalong with your SAS output.*/ optionsdate pageno=4 number; /*Starts from page number 4 with datestamp */ title1'2012 Division I Mens Basketball Scoring Analysis'; /*Set title1*/ title2'Average Games Played by Class'; /*Set Title2 */ footnote1 'Based on Raw Data Prior to Cleansing'; /*Set Footnote */ procsummary data=stats; classclass; varGames; outputout=stats_out MEAN(Games)=avg_games; procprint data = stats_out noobs; formatavg_games 7.4; run;