Chapter Contents |
Previous |
Next |
INPUT |
Category: | Special |
Syntax | |
Arguments | |
Details | |
Comparisons | |
Examples | |
Example 1: Converting Character Values to Numeric Values | |
Example 2: Using PUT and INPUT Functions | |
Example 3: Suppressing Error Messages | |
See Also |
Syntax |
INPUT(source, <? | ??>informat.) |
Details |
The INPUT function enables you to read the value of source by using a specified informat. The informat determines whether the result is numeric or character. Use INPUT to convert character values to numeric values.
Comparisons |
Examples |
This example uses the INPUT function to convert a character value to a numeric value and store it in another variable. The COMMA9. informat reads the value of the SALE variable, stripping the commas. The resulting value, 2115353, is stored in FMTSALE.
data testin; input sale $9.; fmtsale=input(sale,comma9.); datalines; 2,115,353 ;
In this example, PUT returns a numeric value as a character string. The value 122591 is assigned to the CHARDATE variable. INPUT returns the value of the character string as a SAS date value using a SAS date informat. The value 11681 is stored in the SASDATE variable.
numdate=122591; chardate=put(numdate,z6.); sasdate=input(chardate,mmddyy6.);
In this example, the question mark (?) format modifier tells SAS not to print the invalid data error message if it finds data errors. The automatic variable _ERROR_ is set to 1 and input data lines are written to the SAS log.
y=input(x,? 3.1);Because the double question mark (??) format modifier suppresses printing of error messages and input lines and prevents the automatic variable _ERROR_ from being set to 1 when invalid data are read, the following two examples produce the same result:
y=input(x,?? 2.);
y=input(x,? 2.); _error_=0;
See Also |
Functions:
| |||||||||||
Statements:
|
Chapter Contents |
Previous |
Next |
Top of Page |
Copyright 1999 by SAS Institute Inc., Cary, NC, USA. All rights reserved.