Chapter Contents


SAS/ACCESS Software for Relational Databases: Reference

Calculating Statistics

This example shows two ways to use the FREQ procedure with DBMS data. The first method uses descriptors. The second method uses the new SAS/ACCESS LIBNAME statement, which fully supports the new Version 7 and Version 8 features, such as long names up to 32 characters, and accomplishes the same task in an easier and more direct way.

Using the FREQ Procedure with Descriptors

The following example uses the view descriptor VLIB.INV to calculate the percentage of invoices for each country that appears in the table SASDEMO.INVOICE.

proc access dbms=oracle;

/* create access descriptor   */

   create adlib.invoice.access;
   user=scott orapw=tiger;

/* create vlib.inv view      */

   create vlib.inv.view;
   select invoicenum amtbilled
          billedby paidon;

   rename invoicenum = invnum
          amtbilled  = amtbilld;
   format paidon      date9.
          invoicenum  5.0
          billedby    6.0;
   list all;

proc freq data=vlib.inv;
   tables country;
   title 'Data Described by INV';

Using the FREQ Procedure with a SAS/ACCESS LIBNAME

This example uses the FREQ procedure to calculate statistics on the PROC SQL view WORK.INV, created from the DB2 table INVOICE. This example differs from the previous example in that the SAS/ACCESS LIBNAME statement is used to define a SAS libref that references DBMS data. Descriptors are not used. Output from this example is identical to the previous example, except for the column names, which are limited to eight characters when you use descriptors but can be up to 32 characters when you use the SAS/ACCESS LIBNAME statement.

libname mydb2lib db2 ssid=db2;

proc freq data=mydb2lib.invoice(keep=invoicenum amtbilled country
billedby paidon);
  tables country;
  title 'Data Described by INV';

Using the FREQ Procedure shows the one-way frequency table that these examples generate.

Using the FREQ Procedure
                                Data Described by INV                      1
                                  The FREQ Procedure


                                                     Cumulative    Cumulative
    COUNTRY                 Frequency     Percent     Frequency      Percent
    Argentina                      2       11.76             2        11.76
    Australia                      1        5.88             3        17.65
    Brazil                         4       23.53             7        41.18
    USA                           10       58.82            17       100.00

Chapter Contents



Top of Page

Copyright 1999 by SAS Institute Inc., Cary, NC, USA. All rights reserved.