* Bears Example -- bears.sas source code; * Create format for team variable; proc format; value $teamfmt 'X'='Defense' 'O'='Offense' 'K'='Kicking Team'; * Create bears dataset. The value of team (offense or defense) is; * determined by the player's position; data bears; infile 'c:/datasets/bears85.txt' firstobs=3; input name $ 4-20 pos $ 24-25 ht_ft 27 ht_in 29-30 wt_lbs; height = 0.0254 * (ht_ft * 12 + ht_in); weight = 0.4536 * wt_lbs; * Set value of team; if pos='QB'|pos='FB'|pos='RB'|pos='C'|pos='G'|pos='T'|pos='TE'|pos='WR' then team = 'O'; else if pos='K'|pos='P' then team = 'K'; else team = 'X'; * symbol variable to be used for scatterplots; if team = 'O' then symbol = 1; else if team = 'X' then symbol = 2; else symbol = 3; * List of variables to keep in bears dataset; keep name team height weight symbol; label height = 'Height in meters' weight = 'Weight in kilos'; format team $teamfmt.; * Sort bears dataset; proc sort; by name; * Print bears dataset sorted by name; proc print; var name height weight team; title 'Metric Heights and Weights of'; title2 'Chicago Bears Players'; * Create old fashioned typewriter graphics plot; proc plot; plot weight*height; plot weight*height=symbol; * Plot weights vs. heights of bears dataset; * then plot weights vs. heights using; * O, K, or X as plotting symbol; symbol1 V=circle C=blue; symbol2 V=X C=red; symbol3 V=star C=black; proc gplot; plot weight*height; plot weight*height=symbol; * Compute correlations, covariances, means, and sds; proc corr cov; var height weight; * Repeat previous calculations separately by team; proc sort; by team; proc corr cov; var height weight; by team; run;