Previous Page | Next Page

The FORMAT Procedure

Example 3: Writing a Format for Dates Using a Standard SAS Format


Procedure features:

VALUE statement:

HIGH keyword

Data set:

PROCLIB.STAFF.

Formats:

USCurrency. and $CITY..


This example uses an existing format that is supplied by SAS as a formatted value.

Tasks include the following:


Program

This program defines a format called BENEFIT, which differentiates between employees hired on or before 31DEC1979. The purpose of this program is to indicate any employees who are eligible to receive a benefit, based on a hire date on or before December 31, 1979. All other employees with a later hire date are listed as ineligible for the benefit.

 Note about code
libname proclib 'SAS-library-1';
libname library 'SAS-library-2';
 Note about code
options nodate pageno=1 linesize=80 pagesize=40;
 Note about code
   proc format library=library;
 Note about code
      value benefit  low-'31DEC1979'd=[worddate20.]
 Note about code
                    '01JAN1980'd-high='  ** Not Eligible **';
   run;
 Note about code
proc print data=proclib.staff noobs label;
 Note about code
   label salary='Salary in U.S. Dollars';
 Note about code
   format salary uscurrency. site $city. hiredate benefit.;
 Note about code
   title 'PROCLIB.STAFF with a Format for the Variables';
   title2 'Salary, Site, and HireDate';
run;

Output: Listing

                 PROCLIB.STAFF with a Format for the Variables                 1
                           Salary, Site, and HireDate

                              Salary in
                      Id        U.S.
Name                Number     Dollars     Site                   HireDate

Capalleti, Jimmy     2355      $34,072     Birmingham UK       January 30, 1979
Chen, Len            5889      $33,771     Birmingham UK          June 18, 1976
Davis, Brad          3878      $31,509     Plymouth UK       ** Not Eligible **
Leung, Brenda        4409      $55,256     Plymouth UK       September 18, 1974
Martinez, Maria      3985      $78,980     Miami USA         ** Not Eligible **
Orfali, Philip       0740      $80,648     Miami USA         ** Not Eligible **
Patel, Mary          2398      $56,643     York UK           ** Not Eligible **
Smith, Robert        5162      $64,561     INCORRECT CODE    ** Not Eligible **
Sorrell, Joseph      4421      $62,403     Denver USA        ** Not Eligible **
Zook, Carla          7385      $37,010     York UK           ** Not Eligible **

Output: HTML

[untitled graphic]

Previous Page | Next Page | Top of Page