In an
analysis of recent orders, suppose you also want to determine some
statistics for each of your USA customers. In the following SAS program,
the view descriptor VLIB.USAORDR accesses data from the NATURAL DDM
named ORDER, the SAS WHERE statement selects observations that have
a SHIPTO value beginning with a 1, which indicates a USA customer,
and the SAS BY statement sorts the data by order number. (Note that
both ORDERNUM and SHIPTO are
ADABAS descriptor data fields.)
The following example
generates the mean and sum of the length of material ordered and the
fabric charges for each USA customer. Also included are the number
of observations (N) and the number of missing values (NMISS).
proc means data=vlib.usaordr mean sum n nmiss
maxdec=0;
where shipto like "1%";
by ordernum;
var length fabricch;
title "Data Described by VLIB.USAORDR";
run;
The following output
shows the results for this example.
Results of Calculating Statistics Using the MEANS Procedure
Data Described by VLIB.USAORDR
--------------------------------- ORDERNUM=11269 -------------------------------
Variable Label N Nmiss Mean Sum
-------------------------------------------------------------------------------
LENGTH LENGTH 1 0 690 690
FABRICCH FABRICCHARGES 1 0 0 0
-------------------------------------------------------------------------------
--------------------------------- ORDERNUM=11271 -------------------------------
Variable Label N Nmiss Mean Sum
-------------------------------------------------------------------------------
LENGTH LENGTH 1 0 110 110
FABRICCH FABRICCHARGES 1 0 11063836 11063836
-------------------------------------------------------------------------------
--------------------------------- ORDERNUM=11273 -------------------------------
Variable Label N Nmiss Mean Sum
-------------------------------------------------------------------------------
LENGTH LENGTH 1 0 450 450
FABRICCH FABRICCHARGES 1 0 252149 252149
-------------------------------------------------------------------------------
--------------------------------- ORDERNUM=11274 -------------------------------
Variable Label N Nmiss Mean Sum
-------------------------------------------------------------------------------
LENGTH LENGTH 1 0 1000 1000
FABRICCH FABRICCHARGES 1 0 0 0
-------------------------------------------------------------------------------
--------------------------------- ORDERNUM=11276 -------------------------------
Variable Label N Nmiss Mean Sum
-------------------------------------------------------------------------------
LENGTH LENGTH 1 0 1500 1500
FABRICCH FABRICCHARGES 1 0 1934460 1934460
-------------------------------------------------------------------------------
--------------------------------- ORDERNUM=11278 -------------------------------
Variable Label N Nmiss Mean Sum
-------------------------------------------------------------------------------
LENGTH LENGTH 1 0 2500 2500
FABRICCH FABRICCHARGES 1 0 1400825 1400825
-------------------------------------------------------------------------------
For more information
about the MEANS procedure, see the
Base SAS Procedures Guide.