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 the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.