Chapter Contents

Previous

Next
Using the Output Delivery System in the DATA Step

Example 2: Selecting Variables for the Data Component


ODS features:
FILE statement, ODS option:
VARIABLES= suboption
ODS HTML statement:
BODY=
URL= suboption
PUT _ODS_
Format: $CNTRY.

This example selects variables to write to the data component. The output is routed to two ODS destinations: the Listing destination, which is open by default, and the HTML destination, which is opened by the ODS HTML 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
options pagesize=60 linesize=64 nodate pageno=1;
 Note about code
ods html body='selectvars-body.htm';
 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=(variables=(country
                              type
                              kilotons));
 Note about code
      put _ods_;
 Note about code
   datalines;
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;


HTML Output

Body File Produced by the HTML Destination
[HTML Output]


Listing Output

Listing Output Produced by the Listing Destination
                    Leading Grain Producers                    1
                            for 1996
                Country       Grain      Kilotons

             Brazil           Wheat            3302
             Brazil           Rice            10035
             Brazil           Corn            31975
             China            Wheat          109000
             China            Rice           190100
             China            Corn           119350
             India            Wheat           62620
             India            Rice           120012
             India            Corn             8660
             Indonesia        Wheat               .
             Indonesia        Rice            51165
             Indonesia        Corn             8925
             United States    Wheat           62099
             United States    Rice             7771
             United States    Corn           236064


Chapter Contents

Previous

Next

Top of Page

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