![]() | ![]() | ![]() | ![]() |
These sample files and code examples are provided by SAS Institute Inc. "as is" without warranty of any kind, either express or implied, including but not limited to the implied warranties of merchantability and fitness for a particular purpose. Recipients acknowledge and agree that SAS Institute shall not be liable for any damages whatsoever arising out of their use of this material. In addition, SAS Institute will provide no support for the materials contained herein.
/****************************************************************/
/* S A S S A M P L E L I B R A R Y */
/* */
/* NAME: ODSTPL6 */
/* TITLE: Demonstrates Customized Table, Header, and Column */
/* Definitions Used with a Customized Style Definition */
/* PRODUCT: BASE */
/* SYSTEM: ALL */
/* KEYS: ODS HTML PDF STYLE PATH TEMPLATE */
/* PROCS: TEMPLATE UNIVARIATE */
/* DATA: */
/* SUPPORT: UPDATE: */
/* REF: */
/* MISC: */
/* */
/****************************************************************/
/* The following SAS program creates a customized table */
/* definition for the BasicMeasures output object from */
/* PROC UNIVARIATE. */
/* Set the path to search for the table definitions, style */
/* definitions, and so forth, that ODS uses. ODS will look */
/* first in WORK.TEMPLAT, but until we put anything in that */
/* location, it won't find anything there and will use the */
/* defaults in SASHELP.TMPLMST. */
ods path work.templat(update) sashelp.tmplmst(read);
/* Open the HTML and PDF destinations. */
/* Close the listing. */
/* We don't specify a style, so we will get the default */
/* style for each destination. */
ods html body="odstpl6b.htm"
contents="odstpl6c.htm"
frame="odstpl6f.htm";
ods pdf file="odstpl6b.pdf";
ods listing close;
/* These options affect the PDF destinations. */
/* The HTML destination does not use dates and page */
/* numbers. (The options would also affect the Listing if */
/* it were open.) */
options nodate nonumber;
data statepop;
input State $ CityPop_80 CityPop_90 NonCityPop_80 NonCityPop_90 Region @@;
format region 1.;
label citypop_80= '1980 metropolitan pop in millions'
noncitypop_80='1980 nonmetropolitan pop in millions'
citypop_90= '1990 metropolitan pop in millions'
noncitypop_90='1990 nonmetropolitan pop in million'
region='Geographic region';
datalines;
ME .405 .443 .721 .785 1 NH .535 .659 .386 .450 1
VT .133 .152 .378 .411 1 MA 5.530 5.788 .207 .229 1
RI .886 .938 .061 .065 1 CT 2.982 3.148 .126 .140 1
NY 16.144 16.515 1.414 1.475 1 NJ 7.365 7.730 .A .A 1
PA 10.067 10.083 1.798 1.799 1 DE .496 .553 .098 .113 2
MD 3.920 4.439 .297 .343 2 DC .638 .607 . . 2
VA 3.966 4.773 1.381 1.414 2 WV .796 .748 1.155 1.045 2
NC 3.749 4.376 2.131 2.253 2 SC 2.114 2.423 1.006 1.064 2
GA 3.507 4.352 1.956 2.127 2 FL 9.039 12.023 .708 .915 2
KY 1.735 1.780 1.925 1.906 2 TN 3.045 3.298 1.546 1.579 2
AL 2.560 2.710 1.334 1.331 2 MS .716 .776 1.805 1.798 2
AR .963 1.040 1.323 1.311 2 LA 3.125 3.160 1.082 1.060 2
OK 1.724 1.870 1.301 1.276 2 TX 11.539 14.166 2.686 2.821 2
OH 8.791 8.826 2.007 2.021 3 IN 3.885 3.962 1.605 1.582 3
IL 9.461 9.574 1.967 1.857 3 MI 7.719 7.698 1.543 1.598 3
WI 3.176 3.331 1.530 1.561 3 MN 2.674 3.011 1.402 1.364 3
IA 1.198 1.200 1.716 1.577 3 MO 3.314 3.491 1.603 1.626 3
ND .234 .257 .418 .381 3 SD .194 .221 .497 .475 3
NE .728 .787 .842 .791 3 KS 1.184 1.333 1.180 1.145 3
MT .189 .191 .598 .608 4 ID .257 .296 .687 .711 4
WY .141 .134 .329 .319 4 CO 2.326 2.686 .563 .608 4
NM .675 .842 .628 .673 4 AZ 2.264 3.106 .453 .559 4
UT 1.128 1.336 .333 .387 4 NV .666 1.014 .135 .183 4
WA 3.366 4.036 .776 .830 4 OR 1.799 1.985 .834 .858 4
CA 22.907 28.799 .760 .961 4 AK .174 .226 .227 .324 4
HI .763 .836 .202 .272 4
;
proc format;
value regfmt 1='Northeast'
2='South'
3='Midwest'
4='West';
value divfmt 1='New England'
2='Middle Atlantic'
3='Mountain'
4='Pacific';
value usetype 1='Residential Customers'
2='Business Customers';
run;
/* First, let's Customize the Table Definition !!! */
proc template;
/* PROC TEMPLATE stores this table definition in */
/* SASWORK.TEMPLAT, the first (and in this case, only)*/
/* item store in the path that we can write to. */
define table base.univariate.measures;
notes "Basic measures of location and variability";
translate _val_ = ._ into '';
/* The HEADER statement determines the order in which */
/* the table definition uses the headers, which are */
/* defined later. */
header h1 h2 h3;
/* The COLUMN statement determines the order in which */
/* the variables appear. PROC UNIVARIATE names the */
/* variables. */
column VarMeasure VarValue LocMeasure LocValue;
/* These DEFINE blocks define the headers. They specify */
/* the text for each header. By default, a header spans */
/* all columns, so H1 does so. H2 spans the variables */
/* VarMeasure and VarValue. H3 spans LocMeasure and */
/* LocValue. */
define h1;
text "Basic Statistical Measures";
spill_margin=on;
space=1;
end;
define h2;
text "Measures of Variability";
start=VarMeasure
end=VarValue;
end;
define h3;
text "Measures of Location";
start=LocMeasure
end=LocValue;
end;
/* These DEFINE blocks specify characteristics for each */
/* of the variables. There are two differences between */
/* these DEFINE blocks and the ones in the table */
/* definition in SASHELP.TMPLMST. These blocks use */
/* FORMAT= to specify a format of 7.3 for LocValue and */
/* VarValue. They also use STYLE= to specify a bold, */
/* italic font for these two variables. */
define LocMeasure;
print_headers=off;
glue=2;
space=3;
style=RowHeader;
end;
define LocValue;
print_headers=off;
space=5;
format=7.3;
style=Data{font_style=italic font_weight=bold};
end;
define VarMeasure;
print_headers=off;
glue=2;
space=3;
style=RowHeader;
end;
define VarValue;
print_headers=off;
format=7.3;
style=Data{font_style=italic font_weight=bold};
end;
/* End the table definition. */
end;
/* Run the procedure to create the custom table definition. */
run;
/* Generate ODS output from PROC UNIVARIATE. ODS uses the */
/* custom table definition because the template store that */
/* it is in appears first on the ODS PATH statement. ODS */
/* uses this table definition in conjunction with the */
/* default style for each destination because no other */
/* style is specified on the ODS statements that open the */
/* destinations. */
/* The ODS SELECT statement specifies that only the table */
/* of basic measures goes to the open ODS destinations. */
ods select BasicMeasures;
title4 'Basic Measures with the Custom Table Definition';
proc univariate data=statepop mu0=3.5;
var citypop_90;
run;
/* Now, let's add a customized style definition. */
/* Create a customized style definition to use with the */
/* customized table definition. We will change the colors */
/* of several style elements, the font that renders */
/* footnotes, and several aspects of the presentation of */
/* the table that contains the results. Remember, the */
/* point here is to see which style elements affect which */
/* parts of the output. Aesthetics are definitely not a */
/* consideration! */
proc template;
define style customstyle;
/* Use Styles.Default as the basis for the customized */
/* style definition. */
parent=styles.default;
/* Change the foreground color of the text of TITLE */
/* statements to a nondithering red. */
Style SystemTitle from SystemTitle
"Controls system title text." /
Foreground=#FF0000
;
/* Change the foreground color of the text of FOOTNOTE */
/* statements to a nondithering blue. Change the font */
/* to a small, italic font. */
Style SystemFooter from SystemFooter
"Controls system footer text." /
Foreground=#0000FF
font=("Arial, Helvetica, Helv", 2, italic)
;
/* Change the foreground color of the text of the */
/* procedure title to white. Change the background */
/* color to a nondithering green. */
Style ProcTitle from ProcTitle
"Controls procedure title text." /
ForeGround = #FFFFFF
backGround = #00FF00
;
/* Modify attributes of the table that presents the */
/* procedure results. Increase the width of the border. */
/* Change the border color to black. Increase the */
/* amount of space between the cells of the table. */
/* Increase the amount of space between the data in each */
/* cell and the edge of the cell. Remove all rules. */
/* Change the background color to a nondithering yellow. */
/* Note that the table background shows through between */
/* the cells but is not obvious where the background */
/* color of the cells matches the background color of */
/* of the table. */
Style Table from Output
"Abstract. Controls basic output forms." /
BorderWidth = 20
BorderColor = #000000
CellSpacing = 10
CellPadding = 20
Frame = BOX
Rules = NONE
BackGround = #FFFF00
;
/* Change the foreground color of the text of the */
/* cells that contain data to a nondithering blue. */
/* Change the background color to a nondithering yellow. */
Style Data from data
"Default style for data cells in columns." /
ForeGround = #0000FF
BackGround = #FFFF00
;
/* Change the foreground color of the table headers to */
/* black. Set the background to a nondithering pink. */
Style Header from Header
"Controls the headers of a table." /
Foreground = #000000
Background = #FF00FF
;
/* Change the foreground color of the cells that are */
/* row headers to a nondithering yellow. Change the */
/* background color to the same blue that is the */
/* foreground color for the cells that contain data. */
/* Thus, the cells that contain data and the cells that */
/* are row headers use inverse colors. */
Style RowHeader from RowHeader "Controls row headers." /
ForeGround = #FFFF00
Background = #0000FF
;
end;
/* Run the procedure to create the custom style definition. */
run;
/* Specify the custom style definition for all the open */
/* ODS destinations. */
ods html style=customstyle;
ods pdf style=customstyle;
/* The ODS SELECT statement specifies that only the table */
/* of basic measures goes to the open ODS destinations. */
/* You must resubmit this statement before each procedure */
/* step (unless you also specify the PERSIST option). */
ods select BasicMeasures;
/* Rerun the same PROC UNIVARIATE step as before. This */
/* time, however, ODS uses both the customized table */
/* definition and the customized style definition. */
title4 'Basic Measures with a Customized Table Definition';
footnote 'The style element that renders the footnote is';
footnote2 'separate from the style element that renders';
footnote3 ' the title.';
proc univariate data=statepop mu0=3.5;
var citypop_90;
run;
/* Remove the customized table definition. */
/* Remove the customized style. */
proc template;
delete base.univariate.measures;
delete customstyle;
run;
/* All done. Close the destinations and take a look! */
ods _all_ close;
title;
These sample files and code examples are provided by SAS Institute Inc. "as is" without warranty of any kind, either express or implied, including but not limited to the implied warranties of merchantability and fitness for a particular purpose. Recipients acknowledge and agree that SAS Institute shall not be liable for any damages whatsoever arising out of their use of this material. In addition, SAS Institute will provide no support for the materials contained herein.
This code produces HTML and PDF files.Click here to see the PDF output
Results for this sample were generated in SAS Release 9.1.3 Service Pack 2.
| Type: | Sample |
| Topic: | Third Party ==> Output ==> HTML SAS Reference ==> ODS (Output Delivery System) Third Party ==> Output ==> PDF |
| Date Modified: | 2005-08-12 03:02:30 |
| Date Created: | 2005-05-23 13:52:19 |
| Product Family | Product | Host | SAS Release | |
| Starting | Ending | |||
| SAS System | Base SAS | All | 9.1 TS1M3 | n/a |



