Previous Page | Next Page

The FORMAT Procedure

Example 2: Creating a Format for Character Values


Procedure features:

VALUE statement

OTHER keyword

Data set:

PROCLIB.STAFF.

Format: USCurrency.

This example uses a VALUE statement to create a character format that prints a value of a character variable as a different character string.


Program

 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  $city 'BR1'='Birmingham UK'
                   'BR2'='Plymouth UK'
                   'BR3'='York UK'
                   'US1'='Denver USA'
                   'US2'='Miami USA'
                   other='INCORRECT CODE';
   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.;
 Note about code
   title 'PROCLIB.STAFF with a Format for the Variables';
   title2 'Salary and Site';
run;

Output: Listing

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

                                    Salary in
                            Id        U.S.                            Hire
      Name                Number     Dollars     Site                 Date

      Capalleti, Jimmy     2355      $34,072     Birmingham UK     30JAN79
      Chen, Len            5889      $33,771     Birmingham UK     18JUN76
      Davis, Brad          3878      $31,509     Plymouth UK       20MAR84
      Leung, Brenda        4409      $55,256     Plymouth UK       18SEP74
      Martinez, Maria      3985      $78,980     Miami USA         10JAN93
      Orfali, Philip       0740      $80,648     Miami USA         16FEB83
      Patel, Mary          2398      $56,643     York UK           02FEB90
      Smith, Robert        5162      $64,561     INCORRECT CODE    15APR86
      Sorrell, Joseph      4421      $62,403     Denver USA        19JUN93
      Zook, Carla          7385      $37,010     York UK           18DEC91

Output: HTML

[untitled graphic]

Previous Page | Next Page | Top of Page