Chapter Contents

Previous

Next
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

libname proclib 'SAS-data-library-1';
libname library 'SAS-data-library-2';
options nodate pageno=1 linesize=64 pagesize=40;
 Note about code
proc format library=library;


 Note about code
   invalue eval 'O'=4
                'S'=3
                'E'=2
                'C'=1
                'N'=0;
run;
 Note about code
data proclib.points;
   input EmployeeId $ (Q1-Q4) (eval.,+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;
   title 'The PROCLIB.POINTS Data Set';
run;


Output
[HTML Output]  [Listing Output]


Chapter Contents

Previous

Next

Top of Page

Copyright 1999 by SAS Institute Inc., Cary, NC, USA. All rights reserved.