Using ODS, an Easy Approach in Creating HTML Web Pages

SUGI 29 Posters Paper 172-29 Using ODS, an Easy Approach in Creating HTML Web Pages Gregory Newkirk, Washington State Department of Health, Olympia,...
Author: Neal Wheeler
0 downloads 2 Views 333KB Size
SUGI 29

Posters Paper 172-29

Using ODS, an Easy Approach in Creating HTML Web Pages Gregory Newkirk, Washington State Department of Health, Olympia, WA ABSTRACT SAS using ODS (Output Delivery System) helps to create web pages from the data for easier display for the users. ODS has many output destinations; The Listing destination produces monospace output, which is formatted like traditional SAS procedure output. The Printer destination produces output that is formatted for high-resolution printers. The Output destination produces SAS data sets. The HTML destination produces output that is formatted in Hypertext Markup Language. The HTML destination produces a simple web page that is easy to maintain, especially if you are working within a budget. If a simple web page is all you need, the author will show you a quick and efficient way of accomplishing it.

KEY WORDS SAS, ODS, HTML

INTRODUCTION We have developed a process to make Web-based information and services accessible to the public, including individuals with disabilities. This process creates simple web pages with set of standard top and bottom sections for the HTML files. To adequately use this procedure you will need to know Base SAS, ODS (Output Delivery System) and HTML code. With medium skill-level knowledge in these areas you can create simple and easy to read HTML pages ready to be viewed by the public. As a state government entity we have to be mindful of what we display and how we display information on the web. We are constrained by state guidelines designed to make Web-based information and services accessible to the public, including individuals with disabilities (for additional information you can go to http://www.dis.wa.gov/webguidelines/accessibility.htm). This means that the web pages are limited and have constraints (besides HTML code) on frames, script languages, drop down boxes, etc., in order for persons with disabilities to access web material and services. With these constraints in place we have worked on transforming a Microsoft Word document from standard Center for Disease Control and Prevention (CDC) Behavioral Risk Factor Surveillance System (BRFSS) output (see Figure 1) to an HTML page (see Figure 2). As you will notice there are many visual differences between these two pages. BRFSS is the largest, continuously conducted, telephone health survey in the world. It enables the CDC, state health departments, and other health agencies to monitor modifiable risk factors for chronic diseases and other leading causes of death. For additional information you can go to http://www.doh.wa.gov/brfss or http://www.cdc.gov/brfss. With the multiple years of BRFSS files we needed to develop a method to meet the state government standards and to meet our mission to provide an easy and timely approach to the public. Producing these files in an HTML format makes the files faster to download, simpler to make, and easier to read which accomplishes both BRFSS and state government goals.

1

SUGI 29

Posters

(Figure 1.)

2

SUGI 29

Posters

(Figure 2.)

Y o u a re h e re : D O H H o m e » H e a lth D a ta » C H S » B R F S S » E x c e l a n d H T M L F ile s » T a b le

S e a rc h | E m p lo ye e s

S m o k e s E v e ry d a y b y A g e 2 0 0 1 S m o k e s E v e ry day

A g e G ro u p 18 25 35 45 55 65

to 2 4 to 3 4 to 4 4 to 5 4 to 6 4 and over

N u m b e r in P o p u la tio n 78 134 176 166 64 70

P e rc e n t 1 1 0 ,8 7 9 1 3 8 ,6 9 1 1 7 9 ,7 3 6 1 6 2 ,4 8 0 6 7 ,2 4 0 6 7 ,5 0 8

Lower C I %

49 39 39 37 21 17

U pper CI % 40 34 34 32 16 13

59 45 44 41 26 21

Sm okes Som e days by A ge 2001 A g e G ro u p 18 25 35 45 55 65

Sm okes S om e days

to 2 4 to 3 4 to 4 4 to 5 4 to 6 4 and over

N u m b e r in P o p u la tio n 41 73 66 42 15 14

P e rc e n t 5 2 ,4 2 6 7 4 ,2 8 5 7 0 ,9 4 7 3 8 ,3 4 0 1 8 ,3 5 2 1 1 ,4 1 9

Lower C I % 23 21 15 9 6 3

U pper CI % 16 16 12 6 3 1

30 26 19 11 9 4

N o t a t a ll b y A g e 2 0 0 1 A g e G ro u p 18 25 35 45 55 65

to 2 4 to 3 4 to 4 4 to 5 4 to 6 4 and over

N o t a t a ll

N u m b e r in P o p u la tio n 40 138 207 263 202 307

P e rc e n t 6 2 ,2 3 7 1 3 8 ,9 7 8 2 1 3 ,0 7 2 2 4 3 ,6 1 3 2 3 7 ,6 6 2 3 2 4 ,1 6 6

Lower C I % 28 39 46 55 74 80

U pper C I % 18 34 41 50 68 76

D O H H o m e | A c c e ss W a sh in g to n | P riv a c y N o tic e | D isc la im e r/ C o p y rig h t In fo rm a tio n C e n te r fo r H e a lth S ta tis tic s W a s h in g to n S ta te D e p a rtm e n t o f H e a lth 1 1 1 2 S E Q u in c e S tre e t, P .O . B o x 4 7 8 1 4 O ly m p ia , W a s h in g to n , 9 8 5 0 4 -7 8 1 4 L a s t U p d a te : 0 5 /0 6 /2 0 0 3 1 0 :3 7 A M S e n d in q u ire s a b o u t D O H a n d its p ro g ra m s to th e H e a lth C o n s u m e r A s s is ta n c e O ffic e C o m m e n ts o r q u e s tio n s re g a rd in g th is w e b s ite ? S e n d e m a il to K a trin a .S im m o n s

3

37 45 51 60 79 85

SUGI 29

Posters

BASICS In creating the HTML files we used three different SAS program files. Two of these files have information for the top and bottom portions of the HTML pages, that do not contain any of the data tables, we will call these the Header and Footer files. The Header and Footer files allow us to replicate the standard header and footer of a web page. We do this in case there are any changes is done at one place. The main program file contains the SAS and ODS code to produce the web pages of the variable by any particular demographic. The main program files also contain the output from a DATA step to create a data set. Then we use the PROC print statement to display the data from the data set. The ODS is wrapped around the PROC print statement which places the information from the PROC print into a web page. After this process is complete the web pages are ready to be uploaded to the web site. HEADER AND FOOTER FILE

The Header file contains the top portion of the HTML page. The Header file contains are HTML code for Meta tags, html header tags, style, and so on. The contents in this file could be anything (see example in Figure 2). In creating this file we used a DATA null statement (see following code). The DATA null does not create a data set. Instead, it creates a data component. The FILE statement defines the structure of the data component that holds the results of the DATA step. Once the FILE statement opens up the corresponding HTML file the PUT statements insert the HTML code into the HTML file. DATA _null_; FILE reports; PUT ''; PUT 'Center for Health Statistics - WA State Dept. of Health'; PUT ''; PUT ''; PUT ''; PUT ''; PUT ''; PUT ''; PUT ''; PUT ''; PUT ''; PUT ''; RUN; The Footer file contains the bottom portion of the HTML file. Like the Header file, the Footer file can contain any HTML code that you prefer see following code. The Footer file structure is very similar to the Header, except for the content of the PUT statements. This file behaves the same way as the Header file; The DATA null does not create a data set. Instead, it creates a data component and the FILE statement defines the structure of the data component that holds the results of the DATA step.

DATA _null_; FILE reports; PUT ''; PUT ''; 4

SUGI 29

Posters

PUT PUT PUT PUT PUT PUT PUT PUT PUT

''; 'DOH Home|'; ''; 'Access Washington|'; ''; 'Privacy Notice|'; ''; 'Disclaimer/Copyright Information'; '';

PUT ''; PUT ''; PUT ''; PUT ''; PUT 'Center for Health Statistics
'; PUT 'Washington State Department of Health
'; PUT '1112 SE Quince Street, P.O. Box 47814
'; PUT 'Olympia, Washington, 98504-7814'; PUT 'Last Update : 05/06/2003 10:37 AM
'; PUT 'Send inquires about DOH and its programs to the Health Consumer Assistance Office
'; PUT 'Comments or questions regarding this web site? Send email to Katrina.Simmons'; PUT ' '; PUT ''; PUT ''; PUT ''; PUT ''; RUN;

MAIN PROGRAM

The Main program contains the ODS statement to create the HTML file. This file uses the Header and Footer files to populate the top and bottom portion of the HTML file and the ODS statement to populate the contents of the HTML file from the PROC print. The first thing that we need is a blank HTML file, only a filename, no HTML code. To do this look at the following code, we create the HTML file and then the path where this file will be located. ODS listing close; ODS html file="TO_AGE_Days_of_Smoking.htm" (no_top_matter no_bottom_matter) PATH='R:\ehsphl\chs\chs-data\BRFSS\2001'; RUN; ODS html close; ODS listing; The ODS html file statement creates a blank HTML file. The (no_top_matter no_bottom_matter) option turns off the creation of any top or bottom HTML code produced from SAS. The PATH statement tells ODS to store the newly created HTML file in this directory. After the blank HTML file is created, then the next step is to start populating the file with the Header file. The following code demonstrates how this is accomplished. FILENAME reports 'R:\ehsphl\chs\chs-data\BRFSS\2001\TO_AGE_Days_of_Smoking.htm' mod; %INC 'G:\BRFSS\SASPGMS\Web\Top_of_html.sas'; The FILENAME statement creates the variable, reports, that contains the directory and name of the HTML file. This reports variable is used in the Header file, Footer file and the ODS statements. The %INC is an INCLUDE statement. 5

SUGI 29

Posters

The INCLUDE statement inserts the Header file, 'G:\BRFSS\SASPGMS\Web\Top_of_html.sas', into the main program. After this file has been included into the main program, this file runs and populates the header portion of the HTML file. Once the Header file is done populating the top portion of the HTML file, we can start populating the data portion of the file using any type of output statements. We used a PROC print statement to output the data in a table structure to the HTML file. The following code demonstrates this process. ODS listing close; ODS html file=reports (no_top_matter no_bottom_matter) STYLE=*customdefault; PROC print noobs split='*' DATA=one; VAR ageg_wa number total average lower higher; FORMAT total comma7.; LABEL ageg_wa='Age Group' number = 'Smokes Every day' total = 'Number in Population' average = 'Percent' lower ='Lower CI %*' higher ='Upper CI %*'; TITLE1 "Smokes Every day by Age 2001"; RUN; ODS listing close; There are a few things going on in this code that we will take a closer look at. 1.

The ODS html file statement calls up the reports file and does not add any SAS HTML code. Remember that there is code already in the file from the included file before.

2.

The STYLE option sets the colors, fonts, etc. if you prefer a different style than SAS. In this case we created a Customdefault style for the new HTML files.

3.

The PROC print statement populates the data in a table format with the supplied variables in the VAR statement, with some variable in a format supplied by the FORMAT statement, variables are labeled by the LABEL statement and a title is produced. All of this is to represent the table in the HTML file.

Now we have completed the top and table portions of the HTML file. To complete the HTML file, we need to add one more INCLUDE statement. This INCLUDE statement inserts the last of the HTML file, see code below. %INC 'G:\BRFSS\SASPGMS\Web\Bottom_of_html.sas';

CONCLUSION In conclusion we have demonstrated how to produce an HTML web page by using SAS, ODS, and basic knowledge of HTML code. The use of SAS and ODS in this process creates BRFSS’s web-based information and services accessible to the public, including individuals with disabilities.

REFERENCES SAS Institute Inc.(2000), SAS OnlineDoc®, Version 8, Copyright ©2000, SAS Institute Inc.

6

SUGI 29

Posters

CONTACT INFORMATION Your comments and questions are valued and encouraged. Contact the author at: Gregory Newkirk Washington State Department of Health Center for Health Statistics Work Phone: 360 236 4332 Fax: 360 753 4135 Email: [email protected]

SAS and all other SAS Institute Inc. product or service names are registered trademarks or trademarks of SAS Institute Inc. in the USA and other countries. ® indicates USA registration. Other brand and product names are trademarks of their respective companies.

7

SUGI 29

Posters

/* By: Gregory Newkirk Date: 2/25/2003 This takes a SAS program and creates an HTML Document. First this program will create a blank HTML file with a specified name. Then inserts the top portion of the HTML file in. Runs the SAS PROC Print or whatever statement to display the information. Last this program will insert the bottom portion of the HTML file. */ /*************** This portion of code produces the data sets*******************/ options pageno=1 center date; libname brfss "g:\brfss\sasdata\web2001"; /* Frequency of days now smoking=1 Every day*/ data one (keep=ageg_wa number total average lower higher); SET brfss.second_age_2001; number=SMOKEDAY_1_Every_day_N; total=SMOKEDAY_1_Every_day_Sum; average = round((SMOKEDAY_1_Every_day_Mean*100),1); lower = round((SMOKEDAY_1_Every_day_LowerCLMean*100),1); higher = round((SMOKEDAY_1_Every_day_UpperCLMean*100),1); RUN; /*Frequency of days now smoking=2 Some days*/ data two (keep=ageg_wa number total average lower higher); SET brfss.second_age_2001; number=SMOKEDAY_2_Some_days_N; total=SMOKEDAY_2_Some_days_Sum; average = round((SMOKEDAY_2_Some_days_Mean*100),1); lower = round((SMOKEDAY_2_Some_days_LowerCLMean*100),1); higher = round((SMOKEDAY_2_Some_days_UpperCLMean*100),1); RUN; /*Frequency of days now smoking=3 Not at all*/ data three (keep=ageg_wa number total average lower higher); SET brfss.second_age_2001; number=SMOKEDAY_3_Not_at_all_N; total=SMOKEDAY_3_Not_at_all_Sum; average = round((SMOKEDAY_3_Not_at_all_Mean*100),1); lower = round((SMOKEDAY_3_Not_at_all_LowerCLMea*100),1); higher = round((SMOKEDAY_3_Not_at_all_UpperCLMea*100),1); RUN;

/*************** This portion of code produces the HTML Files*******************/ ods listing close; ods html file="TO_AGE_Days_of_Smoking.htm" (no_top_matter no_bottom_matter) path='R:\ehsphl\chs\chs-data\BRFSS\2001'; run; ods html close; ods listing; filename reports 'R:\ehsphl\chs\chs-data\BRFSS\2001\TO_AGE_Days_of_Smoking.htm' mod; %inc 'G:\BRFSS\SASPGMS\Web\Top_of_html.sas'; ods listing close; ods html file=reports (no_top_matter no_bottom_matter) style=customdefault; PROC print noobs split='*' DATA=one; 8

SUGI 29

Posters

var ageg_wa number total average lower higher; format total comma7.; label ageg_wa='Age Group' number = 'Smokes Every day' total = 'Number in Population' average = 'Percent' lower ='Lower CI %*' higher ='Upper CI %*'; TITLE1 "Smokes Every day by Age 2001"; RUN; ods listing close; ods html file=reports (no_top_matter no_bottom_matter) style=customdefault; PROC print noobs split='*' DATA=two; var ageg_wa number total average lower higher; format total comma7.; label ageg_wa='Age Group' number = 'Smokes Some days' total = 'Number in Population' average = 'Percent' lower ='Lower CI %*' higher ='Upper CI %*'; TITLE1 "Smokes Some days by Age 2001"; RUN; ods listing close; ods html file=reports (no_top_matter no_bottom_matter) style=customdefault; PROC print noobs split='*' DATA=three; var ageg_wa number total average lower higher; format total comma7.; label ageg_wa='Age Group' number = 'Not at all' total = 'Number in Population' average = 'Percent' lower ='Lower CI %*' higher ='Upper CI %*'; TITLE1 "Not at all by Age 2001"; RUN; ods html close; ods listing; %inc 'G:\BRFSS\SASPGMS\Web\Bottom_of_html.sas';

/**This portion of code is the Include file for the top portion the HTML file.**/ Top_of_html.sas data _null_; file reports; put ''; put ''; put 'Center for Health Statistics - WA State Dept. of Health'; put ''; put 'A:link {'; put ' COLOR: #000099'; put '}'; put 'A:visited {'; put ' COLOR: #990099'; put '}'; put 'A:hover {'; put ' COLOR: #ff0000'; put '}'; put ''; put ''; put ''; put ' '; put ' '; put ' '; put ' '; put ' '; put ' '; put ''; put ''; put ' '; put ' You are here:  '; put ' DOH Home »'; put ' Health Data »'; put ' CHS »'; put ' BRFSS »'; put ' Excel and HTML Files »'; put ' Table'; put ' '; put ' '; put ' Search '; put ' | Employees'; put ' '; put ' '; put '  '; run; 10

SUGI 29

Posters

/**This portion of code is the Include file for the bottom portion the HTML file.**/ Bottom_of_html.sas data _null_; file reports; put ''; put ''; put ''; put 'DOH Home|'; put ''; put 'Access Washington|'; put ''; put 'Privacy Notice|'; put ''; put 'Disclaimer/Copyright Information'; put ''; put ''; put ''; put ''; put ''; put 'Center for Health Statistics
'; put 'Washington State Department of Health
'; put '1112 SE Quince Street, P.O. Box 47814
'; put 'Olympia, Washington, 98504-7814'; put 'Last Update : 05/06/2003 10:37 AM
'; put 'Send inquires about DOH and its programs to the Health Consumer Assistance Office
'; put 'Comments or questions regarding this web site? Send email to Katrina.Simmons'; put ' '; put ''; put ''; put ''; put ''; run;

11

Suggest Documents