Converting Data with Functions

A Word About Converting Data

The following code automatically converts the variable PayRate from character to numeric.
data hrd.newtemp; 
   set hrd.temp; 
   Salary=payrate*hours; 
run;
You can also use the INPUT function before performing a calculation. The INPUT function converts character data values to numeric values.
You can use the PUT function to convert numeric data values to character values.

Potential Problems of Omitting INPUT or PUT

If you skip INPUT or PUT function when converting data, SAS detects the mismatched variables and tries an automatic character-to-numeric or numeric-to-character conversion. However, this action is not always successful. Suppose each value of PayRate begins with a dollar ...

Get SAS Certification Prep Guide, 4th Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.