INTRODUCTION TO MARKET RESEARCH USING THE SAS SYSTEM /* pp. 9-10 */ proc format; value incfmt 1='Under $20,000' 2='$20,001 - $40,000' 3='$40,001 - $60,000' 4='Over $60,000'; run; data carinfo; format income incfmt.; input idnum $ income yearpur $ type $; cards; 1001 2 1987 used 1002 1 1986 used 1003 3 1988 used 1004 4 1989 new 1005 4 1992 new 1006 4 1987 used 1007 3 1991 new 1008 1 1991 new 1009 4 1989 new 1010 3 1990 used 1011 4 1989 used 1012 3 1992 used 1013 4 1993 new 1014 2 1992 new 1015 2 1989 used 1016 3 1989 new 1017 3 1990 new 1018 4 1990 new 1019 4 1991 new 1020 4 1992 used 1021 4 1992 new 1022 3 1990 new 1023 4 1991 new 1024 1 1987 new 1025 3 1991 used 1026 2 1992 new 1027 2 1989 new 1028 2 1990 new 1029 4 1989 used 1030 3 1991 new 1031 2 1993 new 1032 1 1990 used 1033 4 1992 used 1034 4 1991 new 1035 1 1988 new 1036 4 1991 new 1037 2 1990 used 1038 3 1990 used 1039 4 1993 new 1040 1 1990 used 1041 3 1989 new 1042 1 1988 new 1043 1 1987 used 1044 4 1992 used 1045 3 1990 new 1046 4 1992 new 1047 4 1989 new 1048 3 1992 new 1049 3 1992 used 1050 4 1993 used ; run; proc print data=carinfo; title 'Car Purchase Data'; run; /* pp. 11-12 */ data sample1(drop=z95 z99); z95=1.96; z99=2.58; do interval=5 to 15 by 5; do stddev=5 to 30 by 5; n95=ceil((z95*stddev/interval)**2); n99=ceil((z99*stddev/interval)**2); output; end; end; run; proc print data=sample1; title 'Sample Sizes for 95% and 99% Confidence Intervals'; run; /* pp. 13-14 */ data sample2(drop=z95 z99); z95=1.96; z99=2.58; do interval=.01 to .15 by .01; n95=ceil(.25*(z95**2)/(interval)**2); n99=ceil(.25*(z99**2)/(interval)**2); output; end; run; proc print data=sample2; title 'Sample Sizes for 95% and 99% Confidence Intervals'; run; /* p. 15 */ data approx; set carinfo; if ranuni(7837599)<=.24; run; proc print data=approx; title 'Approximate-Sized Random Sample'; run; /* pp. 17-18 */ data exact(drop=k n); retain k 12 n; if _n_=1 then n=total; set carinfo nobs=total; if ranuni(747088789)<=k/n then do; output; k=k-1; end; n=n-1; if k=0 then stop; run; proc print data=exact; title 'Exact-Sized Random Sample'; run; /* pp. 19-20 */ data replace(drop=i); choice=ceil(ranuni(36830)*n); set carinfo point=choice nobs=n; i+1; if i > 12 then stop; run; proc print data=replace; title 'Random Sample with Replacement'; run; /* pp. 21-24 */ proc freq data=carinfo; tables income / out=bycount noprint; run; proc sort data=carinfo; by income; run; data strat1(drop=k count); merge carinfo bycount(drop=percent); by income; retain k; if first.income then k=3; if ranuni(628825275)<=k/count then do; output; k=k-1; end; count=count-1; run; proc print data=bycount; title 'Count of Individuals by Income Group'; run; proc print data=strat1; title 'Stratified Random Sample of Equal-Sized Groups'; run; /* pp. 24-27 */ proc sort data=carinfo; by income; run; data nselect; set carinfo(keep=income); by income; n+1; if last.income; input k; output; n=0; cards; 2 2 3 5 ; data strat2(drop=k n); merge carinfo nselect; by income; if ranuni(332516)<=k/n then do; output; k=k-1; end; n=n-1; run; proc print data=nselect; title 'Count of Individuals by Income Level'; run; proc print data=strat2; title 'Stratified Random Sample of Unequal-Sized Groups'; run; /* pp. 30-31 */ data _null_; file print; put #3 @20 'CAR PURCHASE SURVEY' // @6 'Do you plan to purchase a new or used car' / @6 'within the next three years?' @53 'Yes' @60 'No' /// @6 'Assuming you need to buy a car today:' /// @11 'Would you prefer to buy it new or used?' @53 'New' @60 'Used' // @11 'What is the maximum amount you would be' / @11 'willing to spend on this car purchase?' @53 '_________'; run; /* pp. 31-33 */ data labels; input name $ 1-20 street $ 22-42 city $ 44-59 state $ 60-61 zip $ 64-68; cards; Johnson, Lee. R. P. O. Box 243 Montgomery, AL 36113 Abbott, Brenda K. 568 Trillion Ct. Denver, CO 80237 Rodriguez, Juan 619 Powell Dr. Charleston, SC 29412 Stevenson, Mary K. 22 Meredith Blvd. Austin, TX 78702 Hawks, Patrick E. Rt. 1, Box 523 Taylorsville, NC 28681 Lee, Chen 123 Maple St. Raleigh, NC 27606 Weinstein, Joseph M. Rt. 4, Box 466 Dixon, IL 61021 Baskowski, Bonnie G. P. O. Box 42 Sacramento, CA 95841 ; proc forms data=labels; line 1 name / lastname; line 2 street; line 3 city state zip / pack; run; /* pp. 33-35 */ proc format; value q1fmt 1='Yes' 0='No'; value q2fmt 1='New' 0='Used'; run; data survey1; format q1 q1fmt. q2 q2fmt. q3 dollar12.2; input idnum $ q1 q2 q3; cards; 1013 0 1 20000 1014 0 0 12000 1019 0 0 10000 1022 1 0 7000 1027 0 1 100 1029 1 1 18000 1033 0 0 . 1036 0 1 18000 1037 1 1 16000 1044 0 1 12000 1046 0 0 8000 1050 1 0 10000 ; proc print data=survey1; var idnum q1 q2 q3; title 'SURVEY1 Data Set'; run; /* p. 45-46 */ data add5; format q1 q1fmt. q2 q2fmt. q3 dollar12.2; input idnum $ q1 q2 q3; cards; 1005 1 1 16000 1011 0 0 10000 1024 1 0 9000 1032 1 1 17000 1039 0 1 10000 ; proc sort data=survey1; by q3; run; proc sort data=add5; by q3; run; data survey2; set survey1 add5; by q3; run; proc print data=survey2; var idnum q1 q2 q3; title 'Interleaving SURVEY1 and ADD5'; run; /* pp. 46-47 */ proc sort data=survey1; by idnum; run; proc sort data=carinfo; by idnum; run; data newdata; merge survey1 (in=S) carinfo; if S; by idnum; run; proc print data=newdata; title 'Merging SURVEY1 and CARINFO'; run; /* p. 47-49 */ data new5; format income incfmt.; input idnum $ income yearpur $ type $; cards; 1003 . 1993 used 1004 3 . . 1010 4 . . 1029 . 1993 new 1042 2 1993 new ; proc print data=new5; var idnum income yearput type; title 'NEW5 Data Set'; run; proc sort data=carinfo; by idnum; run; proc sort data=new5; by idnum; run; data info2; update carinfo new5; by idnum; run; proc print data=carinfo(obs=5); title 'First Five Observations of the CARINFO Data Set'; title2 'Original Master Data Set'; run; proc print data=info2(obs=5); title 'First Five Observations of the INFO2 Data Set'; title2 'Updated Master Data Set'; run; /* pp. 50-52 */ proc univariate data=survey1; var q1 q2 q3; title 'Examining Survey Data'; run; /* pp. 54-57 */ data carsales; title 'Car Sales Data'; title2 'Prospective Sales Figures'; length region $ 9; format revenue dollar10.0; label region='Region' statenm='State' style='Style' quantity='Sales Quantity' revenue='Sales Revenue (in $1000)'; input region $ statenm $ style $ quantity revenue; cards; Midwest IA coupe 200 3671 Midwest IA sedan 252 3863 Midwest IA wagon 263 4362 Midwest IL coupe 374 6964 Midwest IL sedan 485 7493 Midwest IL wagon 188 3111 Midwest IN coupe 330 6111 Midwest IN sedan 123 1890 Midwest IN wagon 108 1748 Midwest MI coupe 163 3003 Midwest MI sedan 486 7508 Midwest MI wagon 167 2749 Midwest MN coupe 200 3670 Midwest MN sedan 253 3865 Midwest MN wagon 174 2862 Midwest MO coupe 366 6588 Midwest MO sedan 506 7806 Midwest MO wagon 180 2907 Midwest OH coupe 238 4321 Midwest OH sedan 408 6164 Midwest OH wagon 275 4491 Midwest WI coupe 166 3004 Midwest WI sedan 312 4755 Midwest WI wagon 259 4211 Northeast CT coupe 348 6249 Northeast CT sedan 459 7124 Northeast CT wagon 179 2924 Northeast MA coupe 138 2577 Northeast MA sedan 469 7161 Northeast MA wagon 99 1593 Northeast ME coupe 226 4104 Northeast ME sedan 313 4840 Northeast ME wagon 123 2040 Northeast NH coupe 390 7177 Northeast NH sedan 427 6595 Northeast NH wagon 171 2837 Northeast NJ coupe 148 2738 Northeast NJ sedan 420 6377 Northeast NJ wagon 112 1850 Northeast NY coupe 297 5448 Northeast NY sedan 511 7774 Northeast NY wagon 114 1875 Northeast PA coupe 194 3601 Northeast PA sedan 223 3381 Northeast PA wagon 66 1080 Northeast RI coupe 303 5514 Northeast RI sedan 198 3065 Northeast RI wagon 229 3787 Northeast VT coupe 338 6276 Northeast VT sedan 267 4103 Northeast VT wagon 232 3782 South AL coupe 319 5831 South AL sedan 390 5983 South AL wagon 183 2983 South AR coupe 339 6246 South AR sedan 235 3625 South AR wagon 166 2738 South DC coupe 112 2099 South DC sedan 159 2438 South DC wagon 67 1077 South DE coupe 314 5696 South DE sedan 302 4612 South DE wagon 138 2248 South FL coupe 347 6302 South FL sedan 417 6344 South FL wagon 272 4500 South GA coupe 296 5312 South GA sedan 515 7792 South GA wagon 108 1790 South KY coupe 275 4929 South KY sedan 521 7922 South KY wagon 263 4244 South LA coupe 306 5630 South LA sedan 350 5347 South LA wagon 222 3635 South MD coupe 316 5659 South MD sedan 275 4203 South MD wagon 228 3670 South MS coupe 361 6623 South MS sedan 526 8105 South MS wagon 133 2146 South NC coupe 292 5339 South NC sedan 353 5380 South NC wagon 126 2059 South SC coupe 297 5335 South SC sedan 231 3501 South SC wagon 124 2026 South TN coupe 358 6444 South TN sedan 267 4081 South TN wagon 166 2726 South VA coupe 260 4836 South VA sedan 395 6116 South VA wagon 237 3916 South WV coupe 174 3129 South WV sedan 343 5307 South WV wagon 99 1627 West AK coupe 191 3528 West AK sedan 87 1367 West AK wagon 66 1100 West AZ coupe 180 3305 West AZ sedan 214 3241 West AZ wagon 87 1414 West CA coupe 175 3200 West CA sedan 238 3168 West CA wagon 62 989 West CO coupe 194 3604 West CO sedan 157 2411 West CO wagon 135 2178 West HI coupe 151 2701 West HI sedan 152 2305 West HI wagon 81 1329 West ID coupe 169 3095 West ID sedan 138 2081 West ID wagon 137 2271 West KS coupe 105 1893 West KS sedan 131 2002 West KS wagon 60 982 West MT coupe 189 3500 West MT sedan 143 2200 West MT wagon 51 845 West ND coupe 187 3454 West ND sedan 175 2698 West ND wagon 52 842 West NE coupe 106 1941 West NE sedan 109 1654 West NE wagon 124 2056 West NM coupe 56 1046 West NM sedan 83 1246 West NM wagon 106 1732 West NV coupe 70 1293 West NV sedan 190 2884 West NV wagon 106 1715 West OK coupe 67 1210 West OK sedan 152 2320 West OK wagon 110 1763 West OR coupe 99 1812 West OR sedan 172 2614 West OR wagon 97 1561 West SD coupe 176 3207 West SD sedan 148 2243 West SD wagon 66 1074 West TX coupe 126 2285 West TX sedan 154 2361 West TX wagon 140 2304 West UT coupe 54 973 West UT sedan 145 2218 West UT wagon 74 1211 West WA coupe 192 3469 West WA sedan 90 1378 West WA wagon 138 2279 West WY coupe 90 1672 West WY sedan 153 2329 West WY wagon 58 955 ; proc sort data=carsales out=cars1(drop=region); where region='Midwest'; by style descending quantity; run; proc print data=cars1 label; by style; id style; sum quantity revenue; var statenm quantity revenue; title3 'Midwest Region'; run; /* pp. 57-60 */ proc sort data=carsales out=cars2; by region style; run; proc means data=cars2 noprint; var quantity revenue; by region style; output out=cars3(drop=_type_ _freq_) sum=; run; proc report data=cars3; title3 'Summary Report'; run; proc report ls=76 ps=60 split="/" headline headskip center; column region style quantity revenue; define region / group format=$9. width=9 spacing=2 left "Region"; define style / display format=$8. width=8 spacing=2 left "Style"; define quantity / sum format=best9. width=9 spacing=2 right "Sales Quantity"; define revenue / sum format=dollar10. width=10 spacing=2 right "Sales Revenue (in $1000)"; break after region / ol ul skip summarize; rbreak after / dol dul skip summarize; compute after; region='Total:'; endcomp; run; /* pp. 62-65 */ options linesize=105; proc tabulate data=carsales format=8.; class region style; var quantity revenue; table region='Sales Region' all='All Regions', (style='Style' all='All Styles')* (quantity='Sales Quantity' revenue='Sales Revenue (in $1000)'*f=dollar10.0)*sum=' ' / rts=16; run; /* pp. 67-69 */ data carout; informat pdate monyy.; format pdate monyy.; label pdate='Purchase Date' style='Car Style' count='Frequency Count' percent='Percent of Total Frequency'; input pdate style $ count percent; cards; jan93 sedan 750 4.1785 jan93 coupe 495 2.7578 jan93 wagon 375 2.0893 feb93 sedan 665 3.7049 feb93 coupe 304 1.6937 feb93 wagon 298 1.6603 mar93 sedan 802 4.4682 mar93 coupe 507 2.8247 mar93 wagon 422 2.3511 apr93 sedan 826 4.6019 apr93 coupe 451 2.5127 apr93 wagon 329 1.8330 may93 sedan 854 4.7579 may93 coupe 373 2.0781 may93 wagon 236 1.3148 jun93 sedan 870 4.8471 jun93 coupe 360 2.0057 jun93 wagon 285 1.5878 jul93 sedan 903 5.0309 jul93 coupe 349 1.9444 jul93 wagon 252 1.4040 aug93 sedan 901 5.0198 aug93 coupe 356 1.9834 aug93 wagon 302 1.6825 sep93 sedan 935 5.2092 sep93 coupe 316 1.7605 sep93 wagon 239 1.3316 oct93 sedan 925 5.1535 oct93 coupe 309 1.7215 oct93 wagon 255 1.4207 nov93 sedan 858 4.7802 nov93 coupe 293 1.6324 nov93 wagon 233 1.2981 dec93 sedan 831 4.6298 dec93 coupe 256 1.4263 dec93 wagon 234 1.3037 ; run; proc sort data=carout; by pdate style; run; /* Title statement used for data listing and plots */ title 'New Car Sales for 1993'; proc print data=carout label; run; /* pp. 69-70 */ proc plot data=carout; plot count*pdate=style; run; /* pp. 70-72 */ goptions border; axis1 order=('01jan93'd to '01jan94'd by month2) minor=(number=1) offset=(3,3); axis2 label=(angle=-90 rotate=90 'Quantity'); proc gplot data=carout; symbol1 i=join color=cyan value=C; symbol2 i=join color=red value=S; symbol3 i=join color=green value=W; plot count*pdate=style / haxis=axis1 vaxis=axis2; run; /* pp. 72-73 */ goptions vpos=48 hpos=85; title 'Car Sales Data'; title2 'Prospective Sales Figures'; proc gchart data=carsales; block style / sumvar=quantity group=region; run; /* pp. 73-74 */ pattern1 value=solid color=cyan; pattern2 value=x1 color=red; pattern3 value=empty; proc gchart data=carsales; hbar region / sumvar=quantity sum subgroup=style; run; /* pp. 74-75 */ proc gchart data=carsales; vbar region / sumvar=revenue sum subgroup=style frame; footnote '(Sales in $1000)'; run; /* pp. 75-76 */ proc gchart data=carsales; pie region / sumvar=quantity slice=outside value=inside percent=inside noheading; footnote; run; /* pp. 76-78 */ /* Assign a libname to the SAS data library at your site */ /* where the SAS/GRAPH map data sets are located. */ /* Ask your SAS site consultant for more details. */ /* The following map programs will not work unless the */ /* libname has been assigned correctly. */ libname maps 'SAS-data-library'; data stsales; set carsales; state=stfips(statenm); run; pattern value=solid; proc gmap map=maps.us data=stsales; where region='Midwest' and style='sedan'; id state; block quantity / discrete nolegend; title3 'Midwest Region'; footnote 'Sedan Sales Quantities'; run; /* pp. 78-80 */ proc means data=stsales noprint; by region statenm; var revenue; id state; output out=stsales1 sum=; run; pattern1 value=mempty color=white; pattern2 value=m3n color=cyan; pattern3 value=m3x color=red; proc gmap map=maps.us data=stsales1; id state; choro revenue / levels=3 coutline=black; title3; footnote '(Sales in $1000)'; run; /* pp. 80-82 */ data us1; set maps.us; select; when (state=42 or state=34 or state=36 or state=09 or state=44 or state=25 or state=50 or state=33 or state=23) region='Northeast'; when (state=27 or state=55 or state=26 or state=19 or state=29 or state=17 or state=18 or state=39) region='Midwest'; when (state=21 or state=54 or state=51 or state=11 or state=24 or state=10 or state=05 or state=47 or state=37 or state=45 or state=22 or state=01 or state=28 or state=13 or state=12) region='South'; otherwise region='West'; end; run; proc sort data=us1; by region state; run; proc gremove data=us1 out=us2; by region; id state; run; proc means data=stsales noprint; by region; var revenue; output out=stsales2 sum=; run; goptions reset=global border; pattern1 value=solid color=cyan; pattern2 value=empty color=green; pattern3 value=r1 color=red; pattern4 value=solid color=black; pattern5 value=m1x color=black; pattern6 value=m2n color=green; pattern7 value=m5x color=red; pattern8 value=m1n color=cyan; proc gmap map=us2 data=stsales2; id region; block revenue / discrete area=1 coutline=black; title 'Car Sales Data'; title2 'Prospective Total Sales Revenue'; footnote '(Sales in $1000)'; run; /* pp. 85-86 */ /* Note: COUNT variable and WEIGHT */ /* statement are used to conserve space */ proc format; value agefmt 1='18-24' 2='25-34' 3='35-44' 4='45-54' 5='55+'; data carfacs; length factor $ 13; format agegrp agefmt.; input agegrp factor $ purch3 $ count; cards; 1 safety Y 3 1 safety N 5 1 reliability Y 2 1 reliability N 3 1 performance Y 12 1 performance N 4 1 unknown/other Y 2 1 unknown/other N 2 2 safety Y 5 2 safety N 7 2 reliability Y 2 2 reliability N 7 2 performance Y 6 2 performance N 2 2 unknown/other Y 2 2 unknown/other N 0 3 safety Y 4 3 safety N 7 3 reliability Y 3 3 reliability N 6 3 performance Y 8 3 performance N 2 3 unknown/other Y 1 3 unknown/other N 2 4 safety Y 5 4 safety N 9 4 reliability Y 6 4 reliability N 6 4 performance Y 4 4 performance N 2 4 unknown/other Y 3 4 unknown/other N 1 5 safety Y 2 5 safety N 7 5 reliability Y 3 5 reliability N 10 5 performance Y 3 5 performance N 2 5 unknown/other Y 1 5 unknown/other N 2 ; title 'Car Survey Data'; options nodate ps=60; proc freq data=carfacs; tables factor*agegrp; weight count; /* WEIGHT statement added */ run; /* pp. 87-88 */ proc freq data=carfacs; tables purch3*factor*agegrp; weight count; /* WEIGHT statement added */ run; /* pp. 88-91 */ proc freq data=carfacs; tables factor*agegrp / measures noprint; weight count; /* WEIGHT statement added */ run; /* pp. 91-94 */ data carsales; input coupon $ purchase $ count; cards; Y Y 13 Y N 47 N Y 4 N N 56 ; proc freq data=carsales order=data; tables coupon*purchase / measures nopercent norow nocol; weight count; run; /* pp. 94-95 */ data carboats; input type $ boat $ count; cards; case Y 6 case N 54 control Y 5 control N 55 ; proc freq data=carboats order=data; tables type*boat / measures nopercent norow nocol; weight count; run; /* p. 96-97 */ proc freq data=carfacs; tables factor*agegrp / nopercent nocol norow chisq; weight count; /* WEIGHT statement added */ run; /* pp. 97-98 */ proc freq data=carsales order=data; tables coupon*purchase / nopercent nocol norow chisq; weight count; run; /* pp. 99-100 */ proc freq data=carfacs; tables purch3*factor*agegrp / cmh noprint; weight count; /* WEIGHT statement added */ run; /* pp. 101-103 */ data carsal3; input dealer coupon $ purchase $ count; cards; 1 Y Y 13 1 Y N 47 1 N Y 4 1 N N 56 2 Y Y 5 2 Y N 45 2 N Y 3 2 N N 47 3 Y Y 15 3 Y N 42 3 N Y 9 3 N N 48 ; proc freq data=carsal3 order=data; tables dealer*coupon*purchase / nopercent nocol norow cmh; weight count; run; /* pp. 103-105 */ data adsales; input pre $ post $ count; cards; Y Y 8 Y N 1 N Y 5 N N 17 ; proc freq data=adsales order=data; tables pre*post / nopercent nocol norow; weight count; run; data mcnemar; df=1; /* assign 1 degree of freedom */ stat=(5-1)**2/(5+1); /* compute the test statistic */ prob=1-probchi(stat,df); /* compute the probability value */ run; proc print data=mcnemar; run; /* p. 108 */ data airline; title 'Airline Cost Data'; input cpm alf asl spa utl; label cpm='Cost per mile' alf='Average load factor' asl='Average flight length' spa='Average seats per aircraft' utl='Average hours per day use of aircraft'; cards; 3.306 .287 1.528 .3522 8.09 3.527 .349 2.189 .3279 9.56 3.959 .362 1.518 .1356 10.80 4.737 .378 0.821 .1290 5.65 3.096 .381 1.692 .3007 10.20 3.689 .394 0.949 .1488 7.94 2.357 .397 3.607 .3390 13.30 2.833 .400 1.495 .3597 8.42 3.313 .405 0.863 .1390 9.57 3.044 .409 0.845 .1390 9.00 2.846 .410 0.840 .1390 9.62 2.341 .412 1.350 .1920 7.91 2.780 .417 2.377 .3287 8.83 3.392 .422 1.031 .1365 8.35 3.856 .425 2.780 .1282 10.60 3.462 .426 0.975 .2025 7.52 2.711 .434 1.912 .3148 8.36 2.743 .439 1.584 .1607 8.43 3.760 .452 1.164 .1270 7.55 3.311 .455 1.236 .1221 7.70 2.404 .466 1.123 .1481 9.38 2.962 .476 0.961 .1236 8.91 3.437 .476 1.416 .1145 7.27 2.906 .478 1.392 .1148 8.71 3.140 .486 0.877 .1060 8.29 2.275 .488 2.515 .3546 9.50 2.954 .495 0.871 .1186 8.44 3.306 .504 1.408 .1345 9.47 2.425 .535 1.576 .1361 10.80 2.971 .539 1.008 .1150 6.84 4.024 .541 0.823 .0943 6.31 2.363 .582 1.963 .1381 8.48 2.258 .591 1.790 .1375 7.87 ; proc print data=airline; run; /* pp. 109-111 */ proc univariate data=airline; run; /* pp. 111-112 */ proc univariate data=airline normal; run; /* pp. 112-115 */ proc plot data=airline; plot cpm*alf; run; proc gplot data=airline; symbol1 value=star; plot cpm*alf; run; /* pp. 114-116 */ proc corr data=airline; run; /* pp. 116-120 */ data adtest; input id $ gender $ scale1 scale2 @@; cards; 101 F 77 92 102 F 63 60 103 M 91 91 104 M 54 47 105 F 85 84 106 M 57 79 107 F 83 89 108 F 38 42 109 F 49 45 110 M 25 28 111 M 90 99 112 M 58 68 113 F 72 70 114 F 80 93 115 M 13 50 116 F 21 39 117 M 60 51 118 F 63 60 119 M 46 70 120 M 77 75 ; proc ttest data=adtest; class gender; var scale2; title 'Customer Satisfaction Data'; run; data adtest2; set adtest; diff=scale2-scale1; run; proc means data=adtest2 n mean stderr t prt; var diff; title 'Customer Satisfaction Data'; run; /* pp. 121-123 */ proc reg data=airline; model cpm=alf; title 'Airline Cost Data'; run; proc gplot data=airline; symbol1 value=star i=r; plot cpm*alf; run; /* pp. 123-124 */ proc reg data=airline; model cpm=alf asl spa utl; run; /* pp. 124-128 */ data adtest2; input id $ gender $ scale1 scale2 buy @@; cards; 101 F 77 92 1 102 F 63 60 0 103 M 91 91 1 104 M 54 47 1 105 F 85 84 0 106 M 57 79 0 107 F 83 89 1 108 F 38 42 0 109 F 49 45 0 110 M 25 28 0 111 M 90 99 1 112 M 58 68 1 113 F 72 70 1 114 F 80 93 1 115 M 13 50 0 116 F 21 39 0 117 M 60 51 0 118 F 63 60 0 119 M 46 70 1 120 M 77 75 0 ; proc print data=adtest2; run; proc logistic data=adtest2 descending; model buy=scale2; output out=adtest3 pred=prob lower=l95 upper=u95; title 'Customer Satisfaction Data'; run; proc print data=adtest3; title 'Predicted Probabilities and Confidence Limits'; run; /* pp. 129-133 */ data housecon; title 'Construction Data'; label date='Date' constr='Construction contracts (in $1,000,000)' intrate='New home mortgage interest rate' hstarts='Housing starts (in 1000s)'; input date:monyy5. constr intrate hstarts; format date monyy5.; cards; JAN83 11358 13.00 91.3 FEB83 11355 12.62 96.3 MAR83 16100 12.97 134.6 APR83 16315 12.02 135.8 MAY83 19205 12.21 174.9 JUN83 20263 11.90 173.2 JUL83 16885 12.02 161.6 AUG83 19441 12.01 176.8 SEP83 17379 12.08 154.9 OCT83 16028 11.80 159.3 NOV83 15401 11.82 136.0 DEC83 13518 11.94 108.3 JAN84 14023 11.80 109.1 FEB84 14442 11.78 130.0 MAR84 17916 11.56 137.5 APR84 17655 11.55 172.7 MAY84 21990 11.68 180.7 JUN84 20036 11.61 184.0 JUL84 19224 11.91 162.1 AUG84 19367 11.89 147.4 SEP84 16923 12.03 148.5 OCT84 18413 12.27 152.3 NOV84 16616 12.27 126.2 DEC84 14220 12.05 98.9 JAN85 15154 11.77 105.4 FEB85 13652 11.74 95.8 MAR85 20004 11.42 145.2 APR85 20692 11.55 176.0 MAY85 22532 11.55 170.5 JUN85 20043 11.31 163.4 JUL85 22047 10.94 160.7 AUG85 21055 10.78 160.7 SEP85 20541 10.69 147.7 OCT85 21715 10.64 173.0 NOV85 17691 10.55 124.1 DEC85 16276 10.47 120.5 JAN86 15417 10.40 115.6 FEB86 16152 10.21 107.2 MAR86 19617 10.04 151.0 APR86 23754 9.87 188.2 MAY86 23050 9.84 186.6 JUN86 23740 9.74 183.6 JUL86 23621 9.89 172.0 AUG86 21884 9.84 163.8 SEP86 21763 9.74 154.0 OCT86 21862 9.57 154.8 NOV86 17998 9.45 115.6 DEC86 17982 9.28 113.0 JAN87 16694 9.14 105.1 FEB87 15729 8.87 102.8 MAR87 22622 8.77 141.2 APR87 23077 8.84 159.3 MAY87 22054 8.99 158.0 JUN87 25703 9.05 162.9 JUL87 24567 9.01 152.4 AUG87 23836 9.01 143.6 SEP87 22418 9.03 152.0 OCT87 23360 8.86 139.1 NOV87 18663 8.92 118.8 DEC87 19224 8.78 85.4 JAN88 15113 8.75 78.2 FEB88 17496 8.76 90.2 MAR88 22257 8.77 128.8 APR88 22344 8.76 153.2 MAY88 24138 8.59 140.2 JUN88 26940 8.90 150.2 JUL88 22309 8.80 137.0 AUG88 24826 8.68 136.8 SEP88 22670 8.90 131.1 OCT88 22223 8.77 135.1 NOV88 19767 9.05 113.0 DEC88 19125 9.04 94.2 JAN89 15776 9.20 100.1 FEB89 15086 9.46 85.8 MAR89 21080 9.63 117.8 APR89 21725 9.88 129.4 MAY89 23796 9.82 131.7 JUN89 24650 10.09 143.2 JUL89 22330 10.06 134.7 AUG89 24128 9.83 122.4 SEP89 23371 9.87 109.3 OCT89 22669 9.77 130.3 ; run; proc autoreg data=housecon; model hstarts=constr intrate / dwprob nlag=4 backstep method=ml; run;