proc format; value WEEK 1="2/20" 2="2/27" 3="3/06" 4="3/13" 5="3/20" 6="3/27" 7="4/03" 8="4/10" 9="4/17" 10="5/08" 11="5/15" 12="5/22"; run; /* Coupons in the Sunday paper, such as SmartSource (TM) Magazine, RedPlum.com (TM), and P&G BrandSaver. I record three kinds of coupons: 1) General coupons that can be redeemed at any grocery store and are valid for a certain value such as $0.50 off, $1.00 off, or $5.00 off. These are entered by value, followed by the number of coupons of that value. 2) Coupons that are "buy one, get one free" (BOGO), up to a certain price. The maximum value is recorded as a single entry with the comment "BOGO." 3) Store-specific coupons such as for Red Lobster or Boston Market. These are lumped together into a single entry with the comment "Store." */ /* general coupons, by value and count */ data Coupons; infile datalines missover; input Week Value Freq Comment $; format Week WEEK. Value 5.2; datalines; 1 0.25 1 1 0.50 3 1 1.00 13 1 1.50 4 1 2.00 3 1 3.00 3 1 5.00 1 2 0.25 4 2 0.35 1 2 0.5 15 2 0.55 4 2 0.75 10 2 1.00 47 2 1.5 4 2 2.00 11 2 2.50 2 2 3.00 7 2 3.50 1 2 4.00 5 2 5.00 6 2 10.00 2 3 0.25 1 3 0.30 1 3 0.35 1 3 0.40 7 3 0.50 8 3 0.55 3 3 0.75 15 3 1.00 50 3 1.50 11 3 2.00 11 3 3.00 5 3 4.00 2 3 6.00 1 3 10.00 1 4 0.25 1 4 0.3 1 4 0.35 1 4 0.4 3 4 0.5 13 4 0.55 2 4 0.6 1 4 0.75 12 4 1.00 40 4 2.00 5 4 3.00 7 4 3.5 1 4 5.00 2 4 10.00 1 5 0.35 1 5 0.4 1 5 0.5 13 5 0.75 3 5 1.00 50 5 1.25 1 5 1.5 8 5 2.00 8 5 2.5 2 5 3.00 6 5 4.00 3 5 5.00 1 5 7.00 1 6 0.35 1 6 0.4 3 6 0.5 16 6 0.55 3 6 0.6 1 6 0.7 1 6 0.75 14 6 1.00 45 6 1.5 4 6 2.00 10 6 3.00 4 6 4.00 2 6 5.00 3 6 7.00 1 6 10.00 1 7 0.3 1 7 0.35 3 7 0.4 1 7 0.5 21 7 0.55 4 7 0.75 12 7 1.00 57 7 1.5 5 7 2.00 13 7 3.00 3 7 4.00 3 7 5.00 4 7 7.00 1 7 10.00 1 7 15.00 1 8 0.25 5 8 0.35 2 8 0.4 2 8 0.5 9 8 0.55 4 8 0.6 3 8 0.75 14 8 1.00 44 8 1.25 1 8 1.5 7 8 2.00 17 8 2.5 1 8 3.00 12 8 4.00 1 8 5.00 5 8 6.00 1 8 10.00 1 9 0.25 2 9 0.4 6 9 0.5 19 9 0.55 9 9 0.6 3 9 0.7 1 9 0.75 18 9 1.00 78 9 1.25 3 9 1.50 15 9 2.00 25 9 2.50 3 9 3.00 14 9 4.00 5 9 5.00 3 9 6.00 1 9 7.00 1 10 0.25 6 10 0.35 5 10 0.4 1 10 0.45 2 10 0.5 27 10 0.55 8 10 0.6 1 10 0.65 1 10 0.75 12 10 1.00 79 10 1.25 2 10 1.5 12 10 2.00 22 10 2.50 2 10 3.00 12 10 4.00 7 10 5.00 10 10 10.00 2 10 15.00 1 11 0.25 1 11 0.3 2 11 0.35 1 11 0.5 12 11 0.55 3 11 0.6 1 11 0.75 7 11 1.00 59 11 1.25 1 11 1.5 10 11 2.00 20 11 2.50 1 11 3.00 8 11 4.00 2 11 5.00 4 11 10.00 1 12 0.25 3 12 0.3 1 12 0.35 3 12 0.4 3 12 0.5 20 12 0.55 6 12 0.6 1 12 0.65 1 12 0.75 16 12 1.00 60 12 1.25 1 12 1.50 7 12 2.00 15 12 3.00 3 12 4.00 2 12 10.00 1 ; run; ods graphics on; title "Distribution of Coupon Amounts"; proc freq data=Coupons; weight freq; table Value /plots=freqplot(scale=percent); run; proc freq data=Coupons order=freq; weight freq; table Value /plots=freqplot(scale=percent); run; proc means data=Coupons N Sum Mean noprint; by Week; freq Freq; var Value; output out=General N=N Sum=General; run; /* Store-specific and BOGO coupons. Also the newspaper's CLAIM of maximum savings */ data Others; input Week Store BOGO Claim; format Week WEEK. Store 5.2 BOGO 5.2 Claim 5.2; datalines; 1 5.00 2.88 43 2 0.00 59.42 242 3 19.00 17.39 150 4 15.00 38.17 149 5 16.00 9.48 153 6 10.00 18.21 164 7 27.50 22.20 210 8 0.00 24.96 227 9 17.00 16.97 208 10 29.00 41.73 331 11 7.00 6.87 207 12 17.99 23.97 181 ; run; data Results; merge General Others; Total = General+Store+BOGO; GpB = General+BOGO; Diff = Total - Claim; label Total = "Actual Potential Savings" Claim = "Claimed Savings" Diff = "Difference between Actual and Claimed Values"; run; title "Maximum Savings By Week"; proc print; var Week General BOGO Store Total Claim; run; data Results; set Results; x=331; y=331; /* add maximum values for identity line */ run; title "Predicted versus Actual Maximum Savings"; proc sgplot data=Results noautolegend; /* identity line */ vector x=x y=y /xorigin=43 yorigin=43 noarrowheads; scatter x=Claim y=Total; xaxis grid; yaxis grid; run; title "Difference between Actual and Claimed Values"; proc univariate data=Results; var DIff; histogram Diff / grid midpoints=0 to 130 by 20 vscale=count; run; proc sort data=results out=f; by Diff;run; proc freq data=f order=data; tables Diff; run; title; proc robustreg data=Results method=lts; model Total = Claim; run; proc reg data=Results; model Total = Claim; run;