* by Tianyue Zhou, Jing Xu ; options nodate nonumber; %macro reporter(data1=, data0=, type=, nname=); data &data1; set &data0; %if &type=1 %then %do; proc report data=&data0 nowd noheader spacing=5 ls=80 ps=30; where name in ( &nname); column name address city state zipcode cartype date workdone parts hours labor total parts=partsmin parts=partsmax; define name--zipcode / order noprint; define cartype / order noprint; define date / order format=date7. order=internal; define workdone / order; define hours / analysis sum format=4.1 width=4; define parts / analysis sum format=8.2 width=7; define labor / computed format=8.2; define total / computed format=8.2; define partsmin / analysis min noprint; define partsmax / analysis max noprint; compute labor; labor=hours.sum*34.50; if date=' ' and workdone=' ' then call define(_col_, "format", "dollar10.2"); endcomp; compute total; total=labor+parts.sum; if date=' ' and workdone=' ' then call define(_col_, "format", "dollar10.2"); endcomp; compute parts; if date=' ' and workdone=' ' then call define(_col_, "format", "dollar10.2"); endcomp; compute before cartype; line @1 name $20.; line @1 address $20.; line @1 city $8. +5 state $2. +5 zipcode $5.; line @1 cartype $20.; line ' '; line @35 'Hours' @48 'Labor' @61 'Parts' @73 'Total'; line @5 'Date' @18 'Description' @34 'Worked' @49 'Cost' @62 'Cost' @74 'Cost'; line @4 7*'-' @16 15*'-' @34 6*'-' @45 8*'-' @58 8*'-' @70 8*'-'; line ' '; endcomp; compute after cartype; line ' '; line ' '; line @18 45*'-'; line @18 '| Parts cost ranged from'partsmin dollar7.2 +1 'to' +1 partsmax dollar7.2'. |'; line @18 45*'-'; endcomp; break after cartype / summarize ol ul page; title 'Girls Tire and Auto Repair'; title2 'Service Record'; footnote1 'Labor cost is calculated at $34.50 per hour'; footnote2 'Total cost = Labor cost + Parts cost'; %end; %if &type=2 %then %do; footnote; title; options formchar='|~---|+|---+=|-/\<>*'; proc report nowd headline ls=100 ps=80 colwidth=20 split='*'; column('Sales figure of different repair as a percent of total sales figure' date workdone parts,(sum pctsum) comment); define date / order format=mmddyy10.; define workdone / order; define parts / sum format=dollar8.2 ' '; define sum / 'total*sales' format=dollar9.2; define pctsum / format=percent8. 'percent*of sales'; define comment /computed width=25 '' flow; compute comment / char length=60; if parts.pctsum gt .15 and workdone ne ' ' then comment='sales substantially above expectations'; else comment=' '; endcomp; break after date/ ol summarize skip suppress; rbreak after / dol dul summarize; %end; %mend reporter; data service; input @1 name $10. @12 address $17. @30 city $7. @38 state $2. @41 zipcode $5. @47 date date7. @55 workdone $15. @70 hours 4.1 / cartype & $25. parts; cards; Bert Allen 1803 Knollton Ct. Bristol NC 29345 01jul93 oil change 0.5 Ford T-bird 1990 9.00 Bert Allen 1803 Knollton Ct. Bristol NC 29345 10jan94 replace brakes 2.0 Ford T-bird 1990 15.00 Bert Allen 1803 Knollton Ct. Bristol NC 29345 20feb94 rotate tires 1.0 Ford T-bird 1990 10.00 Bert Allen 1803 Knollton Ct. Bristol NC 29345 20feb94 transmission 5.5 Ford T-bird 1990 25.00 Sara Jones 202 Stargate Dr. Dart NC 29445 07dec93 align frontend 1.5 Chevy Astro 1992 10.00 Sara Jones 202 Stargate Dr. Dart NC 29445 07dec93 rotate tires 1.0 Chevy Astro 1992 10.00 ; %reporter(data1=out, data0=service, type=2, nname='Bert Allen'); run;