options nocenter ls=80 ; PROC PRINTTO log="descript.out" print="descript.out" new; run; * just read in make price mpg rep78 foreign ; DATA auto ; input MAKE $ PRICE MPG REP78 FOREIGN ; DATALINES; AMC 4099 22 3 0 AMC 4749 17 3 0 AMC 3799 22 3 0 Audi 9690 17 5 1 Audi 6295 23 3 1 BMW 9735 25 4 1 Buick 4816 20 3 0 Buick 7827 15 4 0 Buick 5788 18 3 0 Buick 4453 26 3 0 Buick 5189 20 3 0 Buick 10372 16 3 0 Buick 4082 19 3 0 Cad. 11385 14 3 0 Cad. 14500 14 2 0 Cad. 15906 21 3 0 Chev. 3299 29 3 0 Chev. 5705 16 4 0 Chev. 4504 22 3 0 Chev. 5104 22 2 0 Chev. 3667 24 2 0 Chev. 3955 19 3 0 Datsun 6229 23 4 1 Datsun 4589 35 5 1 Datsun 5079 24 4 1 Datsun 8129 21 4 1 ; RUN; PROC PRINT DATA=auto(obs=10); RUN; * lets examine the variables rep78, mpg, price and foreign ; * we can get frequency tables for them as shown below ; PROC FREQ DATA=auto; TABLES make ; RUN; PROC FREQ DATA=auto; TABLES rep78 ; RUN; PROC FREQ DATA=auto; TABLES foreign ; RUN; * You can specify multiple variables on the TABLES statement, so we ; * could have done this more easily like this ; PROC FREQ DATA=auto; TABLES make price mpg rep78 foreign ; RUN; * Let's look at repair history for domestic and foreign cars. ; PROC FREQ DATA=auto; TABLES rep78*foreign ; RUN; * we can show just the cell percentages to make the table easier to read; PROC FREQ DATA=auto; TABLES rep78*foreign / NOROW NOCOL NOFREQ ; RUN; * notice that the order of the options does not matter as long as ; * they appear after the / ; PROC FREQ DATA=auto; TABLES rep78*foreign / NOFREQ NOROW NOCOL ; RUN; * for summary statistics, we can use PROC MEANS ; PROC MEANS DATA=auto; VAR mpg; RUN: PROC MEANS DATA=auto; CLASS foreign ; VAR mpg; RUN: * for more detailed information, we can use PROC UNIVARIATE ; PROC UNIVARIATE DATA=auto; VAR mpg; RUN; * we might want to get the univariate statistics separately for foreign ; * and domestic cars. to do this, you would be tempted to try ; * PROC UNIVARIATE DATA=auto; * CLASS foreign; * VAR mpg; * RUN; * * Unfortunately, UNIVARIATE does not support the CLASS statement. But ; * we have another way we can do this using SORT and the BY statement ; PROC SORT DATA=auto; BY foreign; RUN; PROC UNIVARIATE DATA=auto; BY foreign; VAR mpg; RUN;