Chapter Contents |
Previous |
Next |
Ways to Specify Informats |
You can specify informats in the following ways:
input @15 style $3. @21 price 5.2;The $w. character informat reads values into the variable STYLE. The w.d numeric informat reads values into the variable PRICE.
For a complete discussion
of the INPUT statement, see
SAS Language Reference: Dictionary.
TempCharacter='98.6'; TemperatureNumber=input(TempCharacter,4.);Here, the INPUT function in combination with the w.d informat reads the character value of TempCharacter as a numeric value and assigns the numeric value 98.6 to TemperatureNumber.
Use
the PUT function with a SAS format to convert numeric
values to character values. For an example of a numeric-to-character conversion,
see the PUT function in
SAS Language Reference: Dictionary. For a complete discussion of the INPUT function, see the INPUT function
in
SAS Language Reference: Dictionary.
informat Birthdate Interview date9.; input @63 Birthdate Interview;
An informat that is associated with an INFORMAT statement behaves like an informat that you specify with a colon (:) format modifier in an INPUT statement. (For details about using the colon (:) modifier, see the INPUT, List statement in SAS Language Reference: Dictionary.) Therefore, SAS uses a modified list input to read the variable so that
If you have coded the INPUT statement to use another style of input, such as formatted input or column input, that style of input is not used when you use the INFORMAT statement.
For more information on how to use modified list input
to read data, see the INPUT, List statement in
SAS Language Reference: Dictionary.
attrib Birthdate Interview informat=date9.; input @63 Birthdate Interview;
An informat that is associated by using the INFORMAT= option in the ATTRIB statement behaves like an informat that you specify with a colon (:) format modifier in an INPUT statement. (For details about using the colon (:) modifier, see the INPUT, List statement in SAS Language Reference: Dictionary.) Therefore, SAS uses a modified list input to read the variable in the same way as it does for the INFORMAT statement.
For more information, see the ATTRIB statement in SAS Language Reference: Dictionary.
Permanent versus Temporary Association |
User-Defined Informats |
When you execute a SAS program that uses user-defined informats, these informats should be available. The two ways to make these informats available are
If you execute a program that cannot locate a user-defined informat, the result depends on the setting of the FMTERR= system option. If the user-defined informat is not found, then these system options produce these results:
System Options | Results |
FMTERR | SAS produces an error that causes the current DATA or PROC step to stop. |
NOFMTERR | SAS continues processing by substituting a default informat. |
To avoid problems, make sure that users of your program have access to all the user-defined informats that are used.
Chapter Contents |
Previous |
Next |
Top of Page |
Copyright 1999 by SAS Institute Inc., Cary, NC, USA. All rights reserved.