dm "log; clear; odsresults; clear;"; options linesize=64 nonumber nodate; *********************************************************************; * AUTHOR: Chris Bilder *; * DATE: 5-18-16 *; * PURPOSE: Working with the placekicking data set *; *********************************************************************; title1 "Chris Bilder, STAT 850"; proc import out=placekick datafile="C:\data\placekick.csv" DBMS=CSV replace; getnames=yes; datarow=2; run; title2 "The placekicking data set"; proc print data=placekick(obs=5); run; title2 "Contingency table for good vs. change"; proc freq data=placekick; tables change*good; run; title2 "Contingency table for good vs. change"; proc freq data=placekick; tables change*good / norow nocol nocum nopercent; run; ***********************************************************************; * Pearson chi-square test; title2 "Contingency table for good vs. change"; proc freq data=placekick; tables change*good / norow nocol nocum nopercent chisq; output out=pearson1 chisq; *Not needed; run; *One way to get test statistic into a data set"; title2 "Pearson chi-square test information"; proc print data=pearson1; run; *Another way to get test statistic into a data set; * I used ods listing in the output window to figure out name of table; title2 "Contingency table for good vs. change"; proc freq data=placekick; tables change*good / norow nocol nocum nopercent chisq; ods output chisq=pearson2; run; title2 "Pearson chi-square test information"; proc print data=pearson2; run; ***********************************************************************; * Get contingency table counts into a data set from proc freq; *METHOD #1; ods listing; *Output also goes to Output window; ods trace on / listing; *Put ODS table names in output window; title2 "Contingency table for good vs. change"; proc freq data=placekick; tables change*good / norow nocol nocum nopercent; run; ods trace off; *ODS table names are no longer printed; ods listing close; *Output now only goes to Results Viewer; title2 "Contingency table for good vs. change"; proc freq data=placekick; tables change*good / norow nocol nocum nopercent; ods output CrossTabFreqs=out_set1; run; title2 "Contingency table from ODS"; proc print data=out_set1; run; *METHOD #2; title2 "Contingency table for good vs. change"; proc freq data=placekick noprint; tables change*good / norow nocol nocum nopercent out=out_set2; run; title2 "Contingency table out option for tables statement"; proc print data=out_set2; run; ***********************************************************************; * Show list option; title2 "Cross-classifications of good vs. change"; proc freq data=placekick; tables change*good / norow nocol nocum nopercent list; run; quit;