Sample 24766: Using suboptions on the FILE PRINT ODS statement in a DATA step
Create HTML output using the DATA step and default ODS
template. Keep only variables named on the VARIABLES=
suboption. Assign a label and format using the
LABEL= and FORMAT= suboptions.
Note: This technique works in RTF and PDF destinations as
well, HTML was chosen for ease of display.
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.
/* Create user-defined format */
proc format;
value $cntry 'BRZ'='Brazil'
'CHN'='China'
'IND'='India';
run;
title 'Leading Grain Producers';
title2 'for 1996';
options nodate;
/* Create dummy data */
data test;
length Country $ 3 Type $ 5;
input year country $ type $ Kilotons;
format country $cntry.;
label type='Grain';
datalines;
1996 BRZ Wheat 3302
1996 BRZ Rice 10035
1996 BRZ Corn 31975
1996 CHN Wheat 109000
1996 CHN Rice 190100
1996 CHN Corn 119350
1996 IND Wheat 62620
1996 IND Rice 120012
1996 IND Corn 8660
;
/* Close listing destination to save resources */
ods listing close;
/* Specify output destination */
ods html body='attribs-body.html';
data _null_;
set test;
/* Specify a new label for the output object, */
/* output only three variables from WORK.TEST, */
/* override the LABEL= for TYPE and apply a new */
/* format to kilotons */
file print ods=(
objectlabel='1996 Grain Production'
variables=(country
type(label='Type of Grain')
kilotons(format=comma12.)
)
);
put _ods_;
run;
ods html close;
ods listing;
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.
SAS Output
Leading Grain Producers
for 1996
Country
Type of 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
Create HTML output using the DATA step and default ODS
template. Keep only variables named on the VARIABLES=
suboption. Assign a label and format using the
LABEL= and FORMAT= suboptions.
Type:
Sample
Topic:
SAS Reference ==> DATA Step Query and Reporting ==> Creating Reports ==> Non Graphical SAS Reference ==> ODS (Output Delivery System)