SAS author's tip: Using informats to filter invalid values

This week's SAS tip is from Ron Cody and his book Cody's Data Cleaning Techniques Using SAS, Second Edition. Ron is the popular author of several bestselling SAS books and has been a SAS user since 1977. Visit Ron's author page for lots of bonus content, including a free chapter from his latest book Cody's Collection of Popular SAS Programming Tasks and How to Tackle Them.

The following excerpt is from SAS Press author Ron Cody and his book "Cody's Data Cleaning Techniques Using SAS, Second Edition" Copyright © 2008, SAS Institute Inc., Cary, North Carolina, USA. ALL RIGHTS RESERVED. (please note that results may vary depending on your version of SAS software) 

Using Informats to Filter Invalid Values

If you want a quick and easy way to test for numeric values in a certain range and simply want to set any other value to missing, you can use a user-defined informat.

PROC FORMAT is used to create three informats (note the use of INVALUE statements instead of the usual VALUE statements). For the informat HR_CK, any numeric value in the range 40 to 100 is unchanged (the keyword _same_ accomplishes this). Any other value is set to missing.

tags: Cody's Collection of Popular SAS Programming Tasks and How to Tackle Them, Cody's Data Cleaning Techniques Using SAS, PROC format, ron cody, sas books, sas press, sas tip

One Comment

  1. Posted November 3, 2012 at 8:56 am | Permalink

    Nice tip Ron!

One Trackback

  1. [...] previously featured tips from Ron Cody's work on this blog: Using informats to filter invalid values, A short-cut for requesting multiple tables, Creating a bar chart using PROC SGPLOT, Computing a [...]

Post a Comment

Your email is never published nor shared. Required fields are marked *

*
*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <p> <pre lang="" line="" escaped=""> <q cite=""> <strike> <strong>