Calculating Statistics

 Using the FREQ Procedure

```proc freq data=vlib.inv;
tables country;
title "Data Described by VLIB.INV";
run;```

Frequency Table for Variable COUNTRY Described by View Descriptor VLIB.INV shows the one-way frequency table this example generates.

Frequency Table for Variable COUNTRY Described by View Descriptor VLIB.INV
 ``` Data Described by VLIB.INV COUNTRY Cumulative Cumulative COUNTRY Frequency Percent Frequency Percent -------------------------------------------------------------- Argentina 2 11.8 2 11.8 Australia 1 5.9 3 17.6 Brazil 4 23.5 7 41.2 USA 10 58.8 17 100.0 Frequency Missing = 2```

 Using the MEANS Procedure

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;```

Statistics on Fabric Length and Charges for Each USA Customer shows the output for this example.

Statistics on Fabric Length and Charges for Each USA Customer
 ``` 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 -------------------------------------------------------------------------------```

 Using the RANK Procedure

```proc rank data=vlib.emps out=mydata.rankex;
var birthdat;
ranks daterank;
run;
proc print data=mydata.rankex;
title "Order of Employee Birthdays";
run;```

VLIB.EMPS accesses data from the NATURAL DDM named EMPLOYEE. Ranking of Employee Birthdays shows the result of this example.

Ranking of Employee Birthdays
 ``` Order of Employee Birthdays OBS EMPID JOBCODE BIRTHDAT LASTNAME DATERANK 1 456910 602 24SEP53 ARDIS 5 2 237642 602 13MAR54 BATTERSBY 6 3 239185 602 28AUG59 DOS REMEDIOS 7 4 321783 602 03JUN35 GONZALES 2 5 120591 602 12FEB46 HAMMERSTEIN 4 6 135673 602 21MAR61 HEMESLY 8 7 456921 602 12MAY62 KRAUSE 9 8 457232 602 15OCT63 LOVELL 11 9 423286 602 31OCT64 MIFUNE 12 10 216382 602 24JUL63 PURINTON 10 11 234967 602 21DEC67 SMITH 13 12 212916 602 29MAY28 WACHBERGER 1 13 119012 602 05JAN46 WOLF-PROVENZA 3```