The PRINT Procedure |
Procedure features: |
| ||||||||||
Other features: |
| ||||||||||
Data set: | EXPREV |
This example
sums expenses and revenues for each region and for all regions
shows the number of observations in each BY group and in the whole report
creates a customized title, containing the name of the region. This title replaces the default BY line for each BY group
creates a CSV file.
Program: Creating a Listing Report |
options nodate pageno=1 linesize=80 pagesize=40 obs=10 nobyline; |
proc sort data=exprev; by sale_type; run; |
proc print data=exprev noobs label sumlabel n='Number of observations for the order type: ' 'Number of observations for the data set: '; |
var country order_date quantity price; |
label sale_type='Sale Type' price='Total Retail Price* in USD' country='Country' order_date='Date' quantity='Quantity'; |
sum price quantity; by sale_type; |
format price dollar7.2; |
title 'Retail and Quantity Totals for #byval(sale_type) Sales'; run; |
options byline; |
Output: Listing |
Retail and Quantity Totals for Catalog Sales 1 Total Retail Price* Country Date Quantity in USD Puerto Rico 1/1/08 14 $51.20 Aruba 1/1/08 30 $123.70 Bahamas 1/1/08 8 $113.40 Bermuda 1/1/08 7 $41.00 British Virgin Islands 1/2/08 11 $40.20 Canada 1/2/08 100 $11.80 ---------------------- -------- ------- Sale Type 170 $381.30 Number of observations for the order type: 6
Retail and Quantity Totals for In Store Sales 2 Total Retail Price* Country Date Quantity in USD Virgin Islands (U.S.) 1/1/08 25 $31.10 Belize 1/2/08 2 $146.40 Cayman Islands 1/2/08 20 $71.00 --------------------- -------- ------- Sale Type 47 $248.50 Number of observations for the order type: 3
Retail and Quantity Totals for Internet Sales 3 Total Retail Price* Country Date Quantity in USD Antarctica 1/1/08 2 $92.60 ======== ======= 219 $722.40 Number of observations for the order type: 1 Number of observations for the data set: 10
Program: Creating a CSV File |
options nodate pageno=1 linesize=80 pagesize=40 obs=10 nobyline;
ods csvall file='your_file.csv'; |
proc sort data=exprev; by sale_type; run;
proc print data=exprev noobs label sumlabel n='Number of observations for the order type: ' 'Number of observations for the data set: ';
var country order_date quantity price;
label price='Total Retail Price* in USD' country='Country' order_date='Date' quantity='Quantity';
sum price quantity; by sale_type;
format price dollar7.2;
title 'Retail and Quantity Totals for #byval(sale_type) Sales'; run;
options byline;
ods csvall close; |
Output: CSV File |
Summing Numeric Variables with One BY Group: CSV Output Viewed with a Microsoft Excel
Copyright © 2010 by SAS Institute Inc., Cary, NC, USA. All rights reserved.