This example uses an INVALUE statement to create a numeric informat
that converts numeric and character raw data to numeric data.
This program converts quarterly employee evaluation grades, which are
alphabetic, into numeric values so that reports can be generated that sum
the grades up as points.
|
libname proclib 'SAS-library-1';
libname library 'SAS-library-2'; |
|
options nodate pageno=1 linesize=64 pagesize=40; |
|
proc format library=library; |
|
invalue evaluation 'O'=4
'S'=3
'E'=2
'C'=1
'N'=0;
run; |
|
data proclib.points;
input EmployeeId $ (Q1-Q4) (evaluation.,+1);
TotalPoints=sum(of q1-q4);
datalines;
2355 S O O S
5889 2 2 2 2
3878 C E E E
4409 0 1 1 1
3985 3 3 3 2
0740 S E E S
2398 E E C C
5162 C C C E
4421 3 2 2 2
7385 C C C N
; |
|
proc print data=proclib.points noobs; |
|
title 'The PROCLIB.POINTS Data Set';
run; |
The PROCLIB.POINTS Data Set 1
Employee Total
Id Q1 Q2 Q3 Q4 Points
2355 3 4 4 3 14
5889 2 2 2 2 8
3878 1 2 2 2 7
4409 0 1 1 1 3
3985 3 3 3 2 11
0740 3 2 2 3 10
2398 2 2 1 1 6
5162 1 1 1 2 5
4421 3 2 2 2 9
7385 1 1 1 0 3
Copyright © 2010 by SAS Institute Inc., Cary, NC, USA. All rights reserved.