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.

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 [...]

  • About this blog

    I’m Maggie Miller and I’ll be providing you the latest updates about SAS books, documentation, tips and industry trends here on the SAS Bookshelf. Follow along with my talented colleagues, and guest posters as we bring the written word to life and share helpful content with our fellow SAS book enthusiasts.
  • Subscribe to this blog

    Enter your email address:

    Other subscription options

  • Archives