/* * This example is a lot fancier. It uses new features in PROC SUMMARY * combined with the Data Step's support for ODS to produce a very * customised report. */ title "ODS RTF Destination Examples"; footnote "ODS RTF is production in version 8.1 of SAS Software"; proc format; value yrFmt . = " All"; value $schFmt ' ' = "All "; run; data Charity; input School $ 1-7 Year 9-12 Name $ 14-20 moneyRaised 22-26 hoursVolunteered 28-29; format moneyRaised dollar8.2; format hoursVolunteered f3.0; format Year yrFmt.; format School schFmt.; label School = "Schools"; label Year = "Years"; datalines; Monroe 1992 Allison 31.65 19 Monroe 1992 Barry 23.76 16 Monroe 1992 Candace 21.11 5 Monroe 1992 Danny 6.89 23 Monroe 1992 Edward 53.76 31 Monroe 1992 Fiona 48.55 13 Monroe 1992 Gert 24.00 16 Monroe 1992 Harold 27.55 17 Monroe 1992 Ima 5.98 9 Monroe 1992 Jack 20.00 23 Monroe 1992 Katie 22.11 2 Monroe 1992 Lisa 18.34 17 Monroe 1992 Tonya 55.16 40 Monroe 1992 Max 26.77 34 Monroe 1992 Ned 28.43 22 Monroe 1992 Opal 32.66 14 Monroe 1993 Patsy 18.33 18 Monroe 1993 Quentin 16.89 15 Monroe 1993 Randall 12.98 17 Monroe 1993 Sam 15.88 5 Monroe 1993 Tyra 21.88 23 Monroe 1993 Myrtle 47.33 26 Monroe 1993 Frank 41.11 22 Monroe 1993 Cameron 65.44 14 Monroe 1993 Vern 17.89 11 Monroe 1993 Wendell 23.00 10 Monroe 1993 Bob 26.88 6 Monroe 1993 Leah 28.99 23 Monroe 1994 Becky 30.33 26 Monroe 1994 Sally 35.75 27 Monroe 1994 Edgar 27.11 12 Monroe 1994 Dawson 17.24 16 Monroe 1994 Lou 5.12 16 Monroe 1994 Damien 18.74 17 Monroe 1994 Mona 27.43 7 Monroe 1994 Della 56.78 15 Monroe 1994 Monique 29.88 19 Monroe 1994 Carl 31.12 25 Monroe 1994 Reba 35.16 22 Monroe 1994 Dax 27.65 23 Monroe 1994 Gary 23.11 15 Monroe 1994 Suzie 26.65 11 Monroe 1994 Benito 47.44 18 Monroe 1994 Thomas 21.99 23 Monroe 1994 Annie 24.99 27 Monroe 1994 Paul 27.98 22 Monroe 1994 Alex 24.00 16 Monroe 1994 Lauren 15.00 17 Monroe 1994 Julia 12.98 15 Monroe 1994 Keith 11.89 19 Monroe 1994 Jackie 26.88 22 Monroe 1994 Pablo 13.98 28 Monroe 1994 L.T. 56.87 33 Monroe 1994 Willard 78.65 24 Monroe 1994 Kathy 32.88 11 Monroe 1994 Abby 35.88 10 Kennedy 1992 Arturo 34.98 14 Kennedy 1992 Grace 27.55 25 Kennedy 1992 Winston 23.88 22 Kennedy 1992 Vince 12.88 21 Kennedy 1992 Claude 15.62 5 Kennedy 1992 Mary 28.99 34 Kennedy 1992 Abner 25.89 22 Kennedy 1992 Jay 35.89 35 Kennedy 1992 Alicia 28.77 26 Kennedy 1992 Freddy 29.00 27 Kennedy 1992 Eloise 31.67 25 Kennedy 1992 Jenny 43.89 22 Kennedy 1992 Thelma 52.63 21 Kennedy 1992 Tina 19.67 21 Kennedy 1992 Eric 24.89 12 Kennedy 1993 Bubba 37.88 12 Kennedy 1993 G.L. 25.89 21 Kennedy 1993 Bert 28.89 21 Kennedy 1993 Clay 26.44 21 Kennedy 1993 Leeann 27.17 17 Kennedy 1993 Georgia 38.90 11 Kennedy 1993 Bill 42.23 25 Kennedy 1993 Holly 18.67 27 Kennedy 1993 Benny 19.09 25 Kennedy 1993 Cammie 28.77 28 Kennedy 1993 Amy 27.08 31 Kennedy 1993 Doris 22.22 24 Kennedy 1993 Robbie 19.80 24 Kennedy 1993 Ted 27.07 25 Kennedy 1993 Sarah 24.44 12 Kennedy 1993 Megan 28.89 11 Kennedy 1993 Jeff 31.11 12 Kennedy 1993 Taz 30.55 11 Kennedy 1993 George 27.56 11 Kennedy 1993 Heather 38.67 15 Kennedy 1994 Nancy 29.90 26 Kennedy 1994 Rusty 30.55 28 Kennedy 1994 Mimi 37.67 22 Kennedy 1994 J.C. 23.33 27 Kennedy 1994 Clark 27.90 25 Kennedy 1994 Rudy 27.78 23 Kennedy 1994 Samuel 34.44 18 Kennedy 1994 Forrest 28.89 26 Kennedy 1994 Luther 72.22 24 Kennedy 1994 Trey 6.78 18 Kennedy 1994 Albert 23.33 19 Kennedy 1994 Che-Min 26.66 33 Kennedy 1994 Preston 32.22 23 Kennedy 1994 Larry 40.00 26 Kennedy 1994 Anton 35.99 28 Kennedy 1994 Sid 27.45 25 Kennedy 1994 Will 28.88 21 Kennedy 1994 Morty 34.44 25 ; run; proc means data=Charity descendTypes charType noprint; class School Year; var moneyRaised; types () School year; output out=top3list sum= mean= idgroup ( max(moneyRaised) out[3](moneyRaised name school year)= ) / inherit autoname; run; ods rtf file='c:\temp\ods4.rtf'; proc print data=Charity; title2 'Simple PROC PRINT of the Input Data Set'; run; proc print data=top3list noobs; title2 'Simple PROC PRINT of the PROC MEANS Output Data Set'; run; /*-- Redirect location of template stores --*/ /*------------------------------------------*/ ods path work.template(update) sashelp.tmplmst(read); /*---------------------------------------------------------*/ /*-- Build a Custom Table Definition for the TopN Report --*/ /*---------------------------------------------------------*/ proc template; /*-- Creates the table definition --*/ /*----------------------------------*/ define table means.topn; /*-- MVAR defines 3 symbols that reference macro --*/ /*-- variables --*/ /*-------------------------------------------------*/ mvar first_year last_year sysdate; /*-- Column defines columns and their order in the table --*/ /*---------------------------------------------------------*/ column class sum mean (raised) (name) (school) (year); /*-- 3 attributes which affect presentation in the --*/ /*-- Listing output only - not in HTML output --*/ /*---------------------------------------------------*/ /*-- Double spaces between rows of output --*/ /*------------------------------------------*/ double_space /*-- Draw continuous line before the 1st row of --*/ /*-- output --*/ /*------------------------------------------------*/ overline /*-- Draw continuous line after the last row of --*/ /*-- output --*/ /*------------------------------------------------*/ underline; /*-- Header statement declares header_1 and header_2 --*/ /*-- as headers in the table and the order in which --*/ /*-- they appear in the output --*/ /*-----------------------------------------------------*/ header table_header_1 table_header_2; /*-- Defines Header_1 --*/ /*----------------------*/ define table_header_1; text "Top Three Fund Raisers"; style=header{font_size=6 foreground=white background=blue}; end; /*-- Defines Header_2 --*/ /*----------------------*/ define table_header_2; /*-- macro value for first_year & last_year are --*/ /*-- resolved when ODS binds the data component --*/ /*-- with the table definition --*/ /*------------------------------------------------*/ text "from " first_year " to " last_year; style=header{font_size=6 foreground=white background=blue}; space=1; end; /*-- Defines Table Footer --*/ /*--------------------------*/ define footer table_footer; /*-- macro value for sysdate is resolved when ODS --*/ /*-- binds the data component w/table definition --*/ /*--------------------------------------------------*/ text " (report generated on " sysdate ")"; style=header{font_size=1 foreground=white background=blue}; end; /*-- Define Column Class --*/ /*-------------------------*/ define class; generic=on; id=on; vjust=top; style=data; end; /*-- Define Column Sum --*/ /*-----------------------*/ define sum; generic=on; header="Total Dollars Raised"; vjust=top; end; /*-- Define Column Mean --*/ /*------------------------*/ define mean; generic=on; header="Average Dollars per Student"; vjust=top; end; /*-- Define Column Raised --*/ /*--------------------------*/ define raised; generic=on; header="Individual Dollars"; end; /*-- Define Column Name --*/ /*------------------------*/ define name; generic=on; header="Student"; end; /*-- Define Column School --*/ /*--------------------------*/ define school; generic=on; header="School"; end; /*-- Define Column Year --*/ /*------------------------*/ define year; generic=on; header="Year"; end; end; run; %let first_year=1992; %let last_year=1994; data _null_; set top3list; title2 'Cutomized Table for TopN Report'; file print ods = ( template='means.topn' columns=( class=school(generic=on) class=year(generic=on) sum=moneyRaised_sum(generic=on) mean=moneyRaised_mean(generic=on) raised=moneyRaised_1(generic=on) raised=moneyRaised_2(generic=on) raised=moneyRaised_3(generic=on) name=name_1(generic=on) name=name_2(generic=on) name=name_3(generic=on) school=school_1(generic=on) school=school_2(generic=on) school=school_3(generic=on) year=year_1(generic=on) year=year_2(generic=on) year=year_3(generic=on) ) ); put _ods_; run; /*-- Remove Custom Table --*/ /*-------------------------*/ proc template; delete means.Topn; run; ods rtf close;