DATA EXPENSE; by Yanqing Yang; OPTIONS NODATE NONUMBER NOCENTER; INFILE 'A:\EXPENSES.TXT'; INPUT TRIPID $ NAME $ TYPE $ EXPENSES ; PROC SORT; by name tripid type; PROC FORMAT; VALUE $TYPEFMT E='ENTERTAIN' F='FOOD' T='TRAVEL'; PROC PRINT; RUN; data _null_; set EXPENSE end=last; by name tripid type; file PRINT notitle; retain subtotal 0 total 0; if _n_ = 1 then do; put @31 "Employee Expenses Report"; put /; put @41 "Expense"; put @20 "Name" @31 "Trip ID" @41 "Type" @56 "Expenses" ; put @20 "ƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒ" /; end; if first.name = 1 then do; put @20 name @; subtotal = 0; end; if first.tripid = 1 then put @31 tripid @; if first.type = 1 then put @41 type $typefmt. @; put @56 expenses dollar9.2; subtotal = subtotal + expenses; total = total + expenses; if last.name = 1 then do; put @56 "ƒƒƒƒƒƒƒƒƒ"; put @56 subtotal dollar9.2 /; end; if last then do; put @56 "========="; put @56 total dollar9.2 /; end; run;