Chapter Contents


Using the Output Delivery System in the DATA Step

Example 3: Specifying Attributes for a Column

ODS features:
FILE statement, ODS option:
OBJECTLABEL= suboption
VARIABLES= suboption
LABEL= attribute
FORMAT= attribute
Format: $CNTRY.

This example assigns a label to the output object that it creates. It also specifies a label and a format for individual columns.

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]

 Note about code
options pagesize=60 linesize=64 nodate pageno=1;
 Note about code
ods html body='attribs-body.htm'
ods printer file='';
 Note about code
title 'Leading Grain Producers'; 
title2 'for 1996'; 
 Note about code
data _null_;
   length Country $ 3 Type $ 5;
   input Year country $ type $ Kilotons;
   if year=1996;
   format country $cntry.;
   label type='Grain';
 Note about code
   file print ods=
 Note about code
      (objectlabel='1996 Grain Production'
 Note about code
                      type(label='Type of Grain')
 Note about code
   put _ods_;
 Note about code
1995 BRZ  Wheat    1516
1995 BRZ  Rice     11236
1995 BRZ  Corn     36276

... more lines of data ...

1996 USA  Wheat    62099
1996 USA  Rice     7771
1996 USA  Corn     236064
 Note about code
ods html close;
ods printer close;

HTML Output

Frame File Produced by the HTML Destination
In this HTML frame file, the object's label, which was supplied by OBJECTLABEL=, appears in the table of contents as the link to the output object. In the body file, the label supplied as an attribute for the variable Grain becomes its column header. The format for Kilotons was also supplied as an attribute in the ODS= option in the FILE statement. [HTML Output]

Printer Output
 Note about figure


Listing Output
 Note about figure
                    Leading Grain Producers                    1
                            for 1996
                Country       Grain      Kilotons

             Brazil           Wheat           3,302
             Brazil           Rice           10,035
             Brazil           Corn           31,975
             China            Wheat         109,000
             China            Rice          190,100
             China            Corn          119,350
             India            Wheat          62,620
             India            Rice          120,012
             India            Corn            8,660
             Indonesia        Wheat               .
             Indonesia        Rice           51,165
             Indonesia        Corn            8,925
             United States    Wheat          62,099
             United States    Rice            7,771
             United States    Corn          236,064

Chapter Contents



Top of Page

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