Previous Page | Next Page

The FORMAT Procedure

Example 4: Converting Raw Character Data to Numeric Values


Procedure feature:

INVALUE statement


This example uses an INVALUE statement to create a numeric informat that converts numeric and character raw data to numeric data.


Program

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.

 Note about code
libname proclib 'SAS-library-1';
libname library 'SAS-library-2';
 Note about code
options nodate pageno=1 linesize=64 pagesize=40;
 Note about code
proc format library=library;
 Note about code
   invalue evaluation 'O'=4
                      'S'=3
                      'E'=2
                      'C'=1
                      'N'=0;
run;
 Note about code
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
;
 Note about code
proc print data=proclib.points noobs;
 Note about code
   title 'The PROCLIB.POINTS Data Set';
run;

Output: Listing

                  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  

Output: HTML

[untitled graphic]

Previous Page | Next Page | Top of Page