Output Delivery System and the DATA Step |
-
ODS
features:
-
|
FILE PRINT ODS statement |
|
PUT _ODS_
statement |
-
ODS destinations:
-
This example uses the DATA step and ODS to create a
listing report. It uses the default table definition (template) for the DATA
step and writes an output object to the LISTING destination (the default).
|
options nodate pageno=1 linesize=64 pagesize=60; |
|
title 'Leading Grain Producers'; |
|
proc format;
value $cntry 'BRZ'='Brazil'
'CHN'='China'
'IND'='India'
'INS'='Indonesia'
'USA'='United States';
run; |
|
data _null_;
|
|
length Country $ 3 Type $ 5;
format country $cntry.;
label type='Grain';
input Year country $ type $ Kilotons;
|
|
file print ods; |
|
put _ods_; |
|
datalines;
1995 BRZ Wheat 1516
1995 BRZ Rice 11236
1995 BRZ Corn 36276
1995 CHN Wheat 102207
1995 CHN Rice 185226
1995 CHN Corn 112331
1995 IND Wheat 63007
1995 IND Rice 122372
1995 IND Corn 9800
1995 INS Wheat .
1995 INS Rice 49860
1995 INS Corn 8223
1995 USA Wheat 59494
1995 USA Rice 7888
1995 USA Corn 187300
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
1996 INS Wheat .
1996 INS Rice 51165
1996 INS Corn 8925
1996 USA Wheat 62099
1996 USA Rice 7771
1996 USA Corn 236064
; |
Listing Output Created with the Default DATA Step Table Definition
|
Leading Grain Producers 1
Country Grain Year Kilotons
Brazil Wheat 1995 1516
Brazil Rice 1995 11236
Brazil Corn 1995 36276
China Wheat 1995 102207
China Rice 1995 185226
China Corn 1995 112331
India Wheat 1995 63007
India Rice 1995 122372
India Corn 1995 9800
Indonesia Wheat 1995 .
Indonesia Rice 1995 49860
Indonesia Corn 1995 8223
United States Wheat 1995 59494
United States Rice 1995 7888
United States Corn 1995 187300
Brazil Wheat 1996 3302
Brazil Rice 1996 10035
Brazil Corn 1996 31975
China Wheat 1996 109000
China Rice 1996 190100
China Corn 1996 119350
India Wheat 1996 62620
India Rice 1996 120012
India Corn 1996 8660
Indonesia Wheat 1996 .
Indonesia Rice 1996 51165
Indonesia Corn 1996 8925
United States Wheat 1996 62099
United States Rice 1996 7771
United States Corn 1996 236064
| |
-
ODS features:
-
|
FILE PRINT ODS statement:
|
|
ODS HTML statement:
|
|
PUT _ODS_
statement |
-
ODS destinations:
-
-
Format:
-
$CNTRY. .
This example selects variables to include
in the output.
The resulting output is produced in two formats, listing and HTML. The listing
output is produced by default, and the HTML output is requested by the ODS
HTML statement.
Note: This example uses filenames that might not be
valid in all operating environments. To successfully run the example in your
operating environment, you might need to change the file specifications. See
ODS HTML Statements for Running Examples in Different Operating Environments.
|
options nodate pageno=1 linesize=64 pagesize=60; |
|
ods html body='your-html-file.html'; |
|
title 'Leading Grain Producers';
title2 'for 1996'; |
|
data _null_;
|
|
length Country $ 3 Type $ 5;
format country $cntry.;
label type='Grain'; |
|
input Year country $ type $ Kilotons;
if year=1996; |
|
file print ods=(variables=(country
type
kilotons)); |
|
put _ods_; |
|
datalines;
1995 BRZ Wheat 1516
1995 BRZ Rice 11236
1995 BRZ Corn 36276
1995 CHN Wheat 102207
1995 CHN Rice 185226
1995 CHN Corn 112331
1995 IND Wheat 63007
1995 IND Rice 122372
1995 IND Corn 9800
1995 INS Wheat .
1995 INS Rice 49860
1995 INS Corn 8223
1995 USA Wheat 59494
1995 USA Rice 7888
1995 USA Corn 187300
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
1996 INS Wheat .
1996 INS Rice 51165
1996 INS Corn 8925
1996 USA Wheat 62099
1996 USA Rice 7771
1996 USA Corn 236064
; |
|
ods html close; |
HTML Body File Produced by ODS
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
-
ODS features:
-
|
FILE PRINT ODS statement:
|
OBJECTLABEL= suboption |
|
VARIABLES= suboption
|
LABEL= suboption |
|
FORMAT=
suboption | | |
|
PUT _ODS_ statement |
-
ODS
destinations:
-
-
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 filenames that might not be
valid in all operating environments. To successfully run the example in your
operating environment, you might need to change the file specifications. See
ODS HTML Statements for Running Examples in Different Operating Environments.
|
options pagesize=60 linesize=64 nodate pageno=1; |
|
ods html body='your_body_file.html'
contents='your_contents_file.html'
frame='your_frame_file.html'; |
|
ods printer file='your_postscript_file.ps'; |
|
title 'Leading Grain Producers';
title2 'for 1996'; |
|
data _null_;
|
|
length Country $ 3 Type $ 5;
format country $cntry.;
label type='Grain'; |
|
input Year country $ type $ Kilotons;
if year=1996; |
|
file print ods= (objectlabel='1996 Grain Production'
variables=(country
type(label='Type of Grain')
kilotons(format=comma12.))
); |
|
put _ods_; |
|
datalines;
1995 BRZ Wheat 1516
1995 BRZ Rice 11236
1995 BRZ Corn 36276
1995 CHN Wheat 102207
1995 CHN Rice 185226
1995 CHN Corn 112331
1995 IND Wheat 63007
1995 IND Rice 122372
1995 IND Corn 9800
1995 INS Wheat .
1995 INS Rice 49860
1995 INS Corn 8223
1995 USA Wheat 59494
1995 USA Rice 7888
1995 USA Corn 187300
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
1996 INS Wheat .
1996 INS Rice 51165
1996 INS Corn 8925
1996 USA Wheat 62099
1996 USA Rice 7771
1996 USA Corn 236064
; |
|
ods _all_ close; |
HTML Frame File Produced by ODS
Printer Output Viewed with Ghostview
|
Leading Grain Producers 1
for 1996
Type
of
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
| |
-
ODS features:
-
|
PROC TEMPLATE |
|
FILE PRINT ODS statement:
|
COLUMNS= suboption:
|
FORMAT= suboption |
|
DYNAMIC= suboption |
|
GENERIC=
suboption | |
|
TEMPLATE= | |
|
PUT _ODS_ statement:
|
column pointer controls |
|
line pointer
controls | |
-
ODS destination:
-
This example shows how to do the
following:
-
create a simple user-defined template (table definition)
with PROC TEMPLATE
-
use a simple user-defined template in the DATA
step
-
use pointer controls in the PUT _ODS_ statement
Note: This example uses filenames that might not be
valid in all operating environments. To successfully run the example in your
operating environment, you might need to change the file specifications. See
ODS HTML Statements for Running Examples in Different Operating Environments.
|
proc template;
define table phonelist;
column name phone;
dynamic colheader;
define name;
generic=on;
header=colheader;
style=data{fontstyle=italic fontsize=5};
end;
define phone;
header='Telephone';
style=datafixed;
end;
end;
run; |
|
ods listing close; |
|
ods rtf body='your_rtf_file.rtf'; |
|
title 'New Subscriber Telephone List'; |
|
proc format;
picture phonenum .='Not available'
other='0000)000-0000' (prefix='(');
run; |
|
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
; |
|
proc sort data=phones;
by last_name;
run; |
|
data _null_;
set phones; |
|
file print ods=(template='phonelist' |
|
columns=
(name=last_name
(generic=on
dynamic=(colheader='Last Name'))
name=first_name
(generic=on
dynamic=(colheader='First Name'))
phone=business_phone
(format=phonenum.)
)
); |
|
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; |
|
ods RTF close; |
RTF Output Viewed with Microsoft Word
Copyright © 2008 by SAS Institute Inc., Cary, NC, USA. All rights reserved.