/*-------------------------------------------------------------------*/ /* SAS(r) Macro Programming Made Easy */ /* by Michele Burlew */ /* Copyright(c) 1998 by SAS Institute Inc., Cary, NC, USA */ /* SAS Publications order # 56516 */ /* ISBN 1-58025-343-1 */ /**********************************************************************/ /* Create the data set used throughout the book. */ /**********************************************************************/ data books.ytdsales; keep section--salepric; attrib section length=$26 label='Section' saleid length=8 label='Sale ID' format=8. saleinit length=$3 label='Sales Person Initials' datesold length=4 label='Date Book Sold' format=mmddyy8. informat=mmddyy8. title length=$50 label='Title of Book' author length=$50 label='First Author' publishr length=$50 label='Publisher' cost length=8 label='Wholesale Cost' format=dollar9.2 listpric length=8 label='List Price' format=dollar9.2 salepric length=8 label='Sale Price' format=dollar9.2; array jan{5} jan1-jan5 (105,40,110,60,85); array feb{5} feb1-feb5 (120,40,130,45,150); array mar{5} mar1-mar5 (115,60,175,75,145); array apr{5} apr1-apr5 (145,55,132,60,131); array may{5} may1-may5 (190,60,165,90,135); array jun{5} jun1-jun5 (160,56,168,84,143); array jul{5} jul1-jul5 (138,50,149,72,140); array aug{5} aug1-aug5 (139,40,153,68,142); array sep{5} sep1-sep5 (150,58,159,80,150); array oct{5} oct1-oct5 (157,52,163,83,155); array nov{5} nov1-nov5 (168,63,173,88,170); array dec{5} dec1-dec5 (190,75,200,95,210); array mos{60} jan1--dec5; array momax{12} momax1-momax12 (30,27,30,29,30,29,30,30,29,30,29,30); array sname{5} $ 26 ('Internet' 'Networks and Communication' 'Operating Systems' 'Programming Languages' 'Web Design'); array prices{13} p1-p13 (15,18,19,22,24,28,29,32,35,39,42,41,76); do m=1 to 12; do i=1 to 5; section=sname{i}; do j=1 to mos{(m-1)*5+i}; day=round(momax{m}*uniform(3),1)+1; datesold=mdy(m,day,2001); title=trim(sname{i}) || ' Title ' || put(j,3.); pval=round(2*normal(3),1) + 7; if pval > 13 then pval=13; else if pval < 1 then pval=1; listpric=prices{pval} + .95; salepric=listpric; if mod(j,8)=0 then salepric=listpric*.9; if mod(j,17)=0 and mod(j,8) ne 0 then salepric=listpric*.8; cost=.7*listpric; if mod(j,12)=0 then cost=.8*listpric; person=mod(day,3); if mod(day,12)=0 then person=1; if mod(day,20)=0 then person=2; if mod(day,15)=0 then person=0; if person=0 then saleinit='MJM'; else if person=1 then saleinit='BLT'; else if person=2 then saleinit='JMB'; output; end; end; end; run;