PROC TEMPLATE features: |
Table attributes:
| DOUBLE_SPACE= |
| OVERLINE= |
| UNDERLINE= | |
DEFINE TABLE statement:
| COLUMN statement |
| DEFINE statement (for columns)
| GENERIC= attribute |
| HEADER= attribute |
| ID= attribute |
| STYLE= attribute |
| VJUST=
attribute | |
| DEFINE statement (for headers)
| TEXT statement |
| STYLE= attribute |
| SPACE= attribute | |
| DEFINE FOOTER
statement |
| HEADER statement |
| MVAR statement | |
|
Other ODS features: |
ODS HTML statement |
FILE statement with ODS= option |
PUT statement with _ODS_
argument |
|
This
example creates a custom table definition for an output data set that PROC
MEANS produces.
Note: This example uses file names that may not be valid
in all operating environments. To successfully run the example in your operating
environment, you may need to change the file specifications. See Alternative ODS HTML Statements for Running Examples in Different Operating Environments. ![[cautionend]](../common/images/cautend.gif)
![Note about code](../common/images/snbut.gif) | options nodate pageno=1 pagesize=60 linesize=72; |
![Note about code](../common/images/snbut.gif) | proc format;
value yrFmt . = " All";
value $schFmt ' ' = "All ";
run; |
![Note about code](../common/images/snbut.gif) | 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";
retain yearmin yearmax;
yearmin=min(yearmin,year);
yearmax=max(yearmax,year);
call symput('first_year',put(yearmin,4.));
call symput('last_year', put(yearmax,4.));
datalines;
Monroe 1992 Allison 31.65 19
Monroe 1992 Barry 23.76 16
Monroe 1992 Candace 21.11 5
... more lines of data ...
Kennedy 1994 Sid 27.45 25
Kennedy 1994 Will 28.88 21
Kennedy 1994 Morty 34.44 25
; |
![Note about code](../common/images/snbut.gif) | 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)= )
/ autoname;
run; |
![Note about code](../common/images/snbut.gif) | proc print data=top3list noobs;
title 'Simple PROC PRINT of the Output Data Set';
run; |
PROC PRINT Listing Output for the Output Data Set from PROC MEANS
Simple PROC PRINT of the Output Data Set 1
money money
Raised_ Raised_ money money money
School Year _TYPE_ _FREQ_ Sum Mean Raised_1 Raised_2 Raised_3
Kennedy All 10 53 $1575.95 $29.73 $72.22 $52.63 $43.89
Monroe All 10 56 $1616.80 $28.87 $78.65 $65.44 $56.87
All 1992 01 31 $892.92 $28.80 $55.16 $53.76 $52.63
All 1993 01 32 $907.92 $28.37 $65.44 $47.33 $42.23
All 1994 01 46 $1391.91 $30.26 $78.65 $72.22 $56.87
All All 00 109 $3192.75 $29.29 $78.65 $72.22 $65.44
Name_1 Name_2 Name_3 School_1 School_2 School_3 Year_1 Year_2 Year_3
Luther Thelma Jenny Kennedy Kennedy Kennedy 1994 1992 1992
Willard Cameron L.T. Monroe Monroe Monroe 1994 1993 1994
Tonya Edward Thelma Monroe Monroe Kennedy 1992 1992 1992
Cameron Myrtle Bill Monroe Monroe Kennedy 1993 1993 1993
Willard Luther L.T. Monroe Kennedy Monroe 1994 1994 1994
Willard Luther Cameron Monroe Kennedy Monroe 1994 1994 1993 |
![Note about code](../common/images/snbut.gif) | options nodate pageno=1 pagesize=60 linesize=72; |
![Note about code](../common/images/snbut.gif) | ods html body='topn-body.htm'; |
![Note about code](../common/images/snbut.gif) | proc template;
define table means.topn; |
![Note about code](../common/images/snbut.gif) | mvar first_year last_year sysdate9; |
![Note about code](../common/images/snbut.gif) | column class sum mean (raised) (name) (school) (year); |
![Note about code](../common/images/snbut.gif) | double_space=on;
overline=on;
underline=on; |
![Note about code](../common/images/snbut.gif) | header table_header_1 table_header_2;
|
![Note about code](../common/images/snbut.gif) | define table_header_1;
text "Top Three Fund Raisers";
style=header{font_size=6};
end; |
![Note about code](../common/images/snbut.gif) | define table_header_2;
text "from " first_year " to " last_year;
space=1;
end; |
![Note about code](../common/images/snbut.gif) | define footer table_footer;
text "(report generated on " sysdate9 ")";
split="*";
style=header{font_size=2};
end; |
![Note about code](../common/images/snbut.gif) | define class;
generic=on;
id=on;
vjust=top;
style=data;
end; |
![Note about code](../common/images/snbut.gif) | define sum;
generic=on;
header="Total Dollars Raised";
vjust=top;
end;
define mean;
generic=on;
header="Average Dollars per Student";
vjust=top;
end;
define raised;
generic=on;
header="Individual Dollars";
end;
define name;
generic=on;
header="Student";
end;
define school;
generic=on;
header="School";
end;
define year;
generic=on;
header="Year";
end; |
![Note about code](../common/images/snbut.gif) | end;
run; |
![Note about code](../common/images/snbut.gif) | data _null_;
set top3list; |
![Note about code](../common/images/snbut.gif) | file print ods = (
template='means.topn' |
![Note about code](../common/images/snbut.gif) | 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)
)
); |
![Note about code](../common/images/snbut.gif) | put _ods_;
run; |
![Note about code](../common/images/snbut.gif) | ods html close; |
Compare this customized output to the PROC PRINT Listing output in
PROC PRINT Listing Output for the Output Data Set from PROC MEANS.
Using a Customized Table to Produce Listing Output
1
Top Three Fund Raisers
from 1992 to 1994
Average
Total Dollars
Dollars per Individual
Schools Years Raised Student Dollars Student School Year
----------------------------------------------------------------------
Kennedy All $1575.95 $29.73 $72.22 Luther Kennedy 1994
$52.63 Thelma Kennedy 1992
$43.89 Jenny Kennedy 1992
Monroe All $1616.80 $28.87 $78.65 Willard Monroe 1994
$65.44 Cameron Monroe 1993
$56.87 L.T. Monroe 1994
All 1992 $892.92 $28.80 $55.16 Tonya Monroe 1992
$53.76 Edward Monroe 1992
$52.63 Thelma Kennedy 1992
All 1993 $907.92 $28.37 $65.44 Cameron Monroe 1993
$47.33 Myrtle Monroe 1993
$42.23 Bill Kennedy 1993
All 1994 $1391.91 $30.26 $78.65 Willard Monroe 1994
$72.22 Luther Kennedy 1994
$56.87 L.T. Monroe 1994
All All $3192.75 $29.29 $78.65 Willard Monroe 1994
$72.22 Luther Kennedy 1994
$65.44 Cameron Monroe 1993
----------------------------------------------------------------------
(report generated on 12MAR1999) |
Using a Customized Table to Produce HTML Output
Copyright 1999 by SAS Institute Inc., Cary, NC, USA. All rights reserved.