Chapter Contents

Previous

Next
Using the Output Delivery System in the DATA Step

Example 4: Using a Simple User-Defined Definition


ODS features:
PROC TEMPLATE
FILE statement, ODS option:
COLUMNS= suboption
FORMAT= attribute
DYNAMIC= attribute
GENERIC= attribute
TEMPLATE=
PUT _ODS_:
column pointer controls
line pointer controls

This example illustrates how to use a simple user-defined table definition in the DATA step. It also illustrates the use of pointer controls in the PUT _ODS_ statement.

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]


Program


 Note about code
/* Define the table definition 'phonelist' */
proc template;
define table phonelist;
   column name phone;
   dynamic colheader;
   define name;
      generic=on;
      header=colheader;
      style=data{font_style=italic font_size=5};
   end;

   define phone;
      header='Telephone';
      style=datafixed;
   end;
end;
run;
 Note about code
ods listing close;
 Note about code
ods html body='ptcntrl-body.htm';
 Note about code
title 'New Subscriber Telephone List';
 Note about code
proc format;
   picture phonenum .='Not available'
                other='0000)000-0000' (prefix='(');
run;
 Note about code
data phones;
   length first_name $20 last_name $25;
   input first_name $ last_name $ business_phone home_phone;
   datalines;
Jerome Johnson 9193191677 9198462198
Romeo Montague 8008992164 3609736201
Imani Rashid 5088522146 5083669821
Palinor Kent . 9197823199
Ruby Archuleta . .
Takei Ito 7042982145 .
Tom Joad 2099632764 2096684741
;
 Note about code
proc sort data=phones;
by last_name;
run;
 Note about code
data _null_;
set phones;
 Note about code
file print ods=(template='phonelist'
 Note about code
                columns=
                         (name=last_name
                           (generic=on
                            dynamic=(colheader='Last Name'))
                          name=first_name
                           (generic=on
                            dynamic=(colheader='First Name'))
                          phone=business_phone
                            (format=phonenum.)
                          )
               );
 Note about code
if (missing(business_phone)) then
   put _ods_ @3 home_phone;
else if (missing(home_phone)) then 
   put _ods_;
else
   put _ods_ / @3 home_phone;
run;
 Note about code
ods html close;


HTML Output

[HTML Output]


Chapter Contents

Previous

Next

Top of Page

Copyright 1999 by SAS Institute Inc., Cary, NC, USA. All rights reserved.