Tuesday, December 2, 2008

Useful informat modifiers

The world is not perfect. Likewise, raw data is not always clean.
With SAS powerful input facility, we can handle different format data.

There are four input styles: column, list, formatted and named.
In my opinion, the most powerful and interesting style is formatted.

Here are 4 useful modifiers, which can be used in formatted input.
#1: colon format modifier (:)
character data that contains more than eight characters
numeric data that contains special characters.
#2: ampersand format modifier (&)
character data that contains single embedded blanks.
Note: The only restriction is that at least two blanks must divide each value from the next data value in the record.
#3: double question mark modifier (??)
Suppress the error messages resulting from invalid data/argument. This can be used in INPUT function and INPUT statement. The modifier also resets the automatic variable _ERROR_ to 0.
#4: single question mark modifier (?)
Suppress the error messages resulting from invalid data/argument. This can be used in INPUT function and INPUT statement.

Compared with informat modifier, there are format modifier for PUT function at below.
-L left aligns the value.
-C centers the value.
-R right aligns the value.

Obviously, format modifier is not much useful.

No comments: