pungitore_33

Untitled

Nov 27th, 2020 (edited)
212
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
SAS 2.00 KB | None | 0 0
  1. /*IMPORTING 2019 NFL DATA*/
  2. FILENAME REFFILE 'C:/Users/Zac Pungitore/Desktop/602 Stats for data analytics/Term Project/2019_NFLStats.xlsx';
  3.  
  4. PROC IMPORT DATAFILE=REFFILE
  5.     DBMS=XLSX
  6.     OUT=STATS.NFL2019 REPLACE;
  7.     GETNAMES=YES;
  8. RUN;
  9. /*REMOVING * AND + FROM NAME COLUMN*/
  10. DATA STATS.TECHDOC;
  11.     SET STATS.NFL2019;
  12.     Player=compress(player,'*');
  13.     Player=compress(player,'+');
  14. RUN;
  15.  
  16. /*Sorting Data by Scrimmage Yards*/
  17. Proc sort data=stats.techdoc;
  18.     by descending yscm;
  19. run;
  20.  
  21. /*Where statements to filter by position*/
  22. proc print data=stats.techdoc;
  23.     where pos="qb";
  24. run;
  25. proc print data=stats.techdoc;
  26.     where pos="rb";
  27. run;
  28. proc print data=stats.techdoc;
  29.     where pos="wr";
  30. run;
  31. proc print data=stats.techdoc;
  32.     where pos="te";
  33. run;
  34.  
  35. /*where statements using and or*/
  36. proc print data=stats.techdoc;
  37.     where pos="RB" and RRTD>10 and YScm>1200;
  38. run;
  39. proc print data=stats.techdoc;
  40.     where yds>500 and yds_1>1000;
  41. run;
  42. proc print data=stats.techdoc;
  43.     where 800<yds_1<1000 or rrtd>15;
  44. run;
  45. proc print data=stats.techdoc;
  46.     where att>80 and 60<rec<100;
  47. run;
  48. proc print data=stats.techdoc;
  49.     where lng>50 or yds>1000;
  50. run;
  51.  
  52. /*Special WHERE statements*/
  53. proc print data=stats.techdoc;
  54.     where POS is missing;
  55. run;
  56. proc print data=stats.techdoc;
  57.     where rec between 80 and 120;
  58. run;
  59. proc print data=stats.techdoc;
  60.     where player like "%Jones";
  61. run;
  62.  
  63. /*Using macrovariables*/
  64. %let pos=RB;
  65. proc print data=stats.techdoc;
  66.     where pos="&pos";
  67. run;
  68. proc means data=stats.techdoc;
  69.     where pos="&pos";
  70. run;
  71. proc freq data=stats.techdoc;
  72.     where pos="&pos";
  73. run;
  74.  
  75. /*Drop and Keep columns*/
  76. data stats.filteredTECHDOC;
  77.     SET STATS.TECHDOC;
  78.     where g=16;
  79.     KEEP Player Age Pos G rec yds td att yds_1 td_1 yscm rrtd;
  80. run;
  81.  
  82. /*using If/Then Statements to filter*/
  83. DATA STATS.ifthenTECHDOC;
  84. SET STATS.filteredTECHDOC;
  85.     FORMAT POS $UPCASE2.;
  86.     IF POS="QB" THEN DELETE;
  87.     IF POS="WR" THEN DELETE;
  88.     IF POS="TE" THEN DELETE;
  89.     IF ATT>=40 THEN POS="RB";
  90.     IF ATT<40 THEN DELETE;
  91.     IF POS=" " THEN DELETE;
  92. run;
Add Comment
Please, Sign In to add comment