This example creates a format and shows how
to use ranges with character
strings.
libname proclib 'SAS-library';
![Note about code](../../../../common/63294/HTML/default/images/snbut.gif) |
options nodate pageno=1 linesize=80 pagesize=40; |
![Note about code](../../../../common/63294/HTML/default/images/snbut.gif) |
data train;
set proclib.staff(keep=name idnumber);
run; |
![Note about code](../../../../common/63294/HTML/default/images/snbut.gif) |
proc print data=train noobs; |
![Note about code](../../../../common/63294/HTML/default/images/snbut.gif) |
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](../../../../common/63294/HTML/default/images/snbut.gif) |
proc format; |
![Note about code](../../../../common/63294/HTML/default/images/snbut.gif) |
value $skilltest 'a'-<'e','A'-<'E'='Test A'
'e'-<'m','E'-<'M'='Test B'
'm'-'z~','M'-'Z~'='Test C';
run; |
![Note about code](../../../../common/63294/HTML/default/images/snbut.gif) |
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; |
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
![[untitled graphic]](images/chap18-ex8b.gif)
Copyright © 2010 by SAS Institute Inc., Cary, NC, USA. All rights reserved.