Previous Page | Next Page

The FORMAT Procedure

Example 8: Writing Ranges for Character Strings


Data sets:

PROCLIB.STAFF.


This example creates a format and shows how to use ranges with character strings.


Program

libname proclib 'SAS-library';

 Note about code
options nodate pageno=1 linesize=80 pagesize=40;
 Note about code
data train;
   set proclib.staff(keep=name idnumber);
run;
 Note about code
proc print data=train noobs;
 Note about code
   title 'The TRAIN Data Set without a Format';
run;

                      The TRAIN Data Set without a Format                      1

                                                 Id
                           Name                Number

                           Capalleti, Jimmy     2355 
                           Chen, Len            5889 
                           Davis, Brad          3878 
                           Leung, Brenda        4409 
                           Martinez, Maria      3985 
                           Orfali, Philip       0740 
                           Patel, Mary          2398 
                           Smith, Robert        5162 
                           Sorrell, Joseph      4421 
                           Zook, Carla          7385 
 Note about code
proc format;
 Note about code
   value $skilltest  'a'-<'e','A'-<'E'='Test A'
                 'e'-<'m','E'-<'M'='Test B'
                 'm'-'z~','M'-'Z~'='Test C';
run;
 Note about code
proc report data=train nowd headskip;
   column name name=test idnumber;
   define test / display format=$skilltest. 'Test';
   define idnumber / center;
   title 'Test Assignment for Each Employee';
run;

Output: Listing

                       Test Assignment for Each Employee                       1

                       Name              Test    IdNumber
                                                         
                       Capalleti, Jimmy  Test A    2355  
                       Chen, Len         Test A    5889  
                       Davis, Brad       Test A    3878  
                       Leung, Brenda     Test B    4409  
                       Martinez, Maria   Test C    3985  
                       Orfali, Philip    Test C    0740  
                       Patel, Mary       Test C    2398  
                       Smith, Robert     Test C    5162  
                       Sorrell, Joseph   Test C    4421  
                       Zook, Carla       Test C    7385  

Output: HTML

[untitled graphic]

Previous Page | Next Page | Top of Page