Sierra Information Services 19229 Sonoma Highway #264 Sonoma, California 95476 USA 707 996 7380 Andrew@sierrainformation.com http://www.ierrSormaaInf.itnocom
• What You Will Learn in the Presentation Overview of Core Format Functionalities • Can’t cover everything in 50 minutes! Using Formats to“alter the external representation of the values of variables in a SAS data set • SAS Supplied Formats • Creating Your Own Formats Using PROC FORMAT Value Formats Picture Formats • Permanent vs. Temporary Formats • Creating SAS Formats Using Variables in SAS Data Sets Input Control Data Sets
• A Format is an instruction that the SAS System uses when portraying, or otherwise using, the values of variables in a SAS data set Character Formats Numeric Formats • SAS-Supplied Formats • User Created Formats PROC FORMAT
What Does a SAS Format “do? • Where are SAS Formats “kept? SAS-Supplied Formats • Part of the SAS System InFormat Catalogs • Special entry type in SAS Data Libraries • Automatically by PROC FORMAT the first time you create a Format in that library FORMORK.WATS • Location of temporary user-created formats LIBNAME.FORMATS • Location(s) of permanent user-created formats where LIBNAMEname of the SAS Library Reference (LIBREF)is the
• Formats “alter the external representation of the values of variables stored in SAS data sets • The “internal value remains the same, but how we “see it, “outside of the data set, is controlled by the Format we choose to associate to the variable.
Formatted Value 16537 04/11/05 04/11/2005 11/04/2005 11APR05 11APR2005 APR2005 2 2005 05Q2 2005Q2 April 11, 2005 2 Monday Monday, April 11, 2005 11 April 2005
Format Applied No Format Applied MMDDYY8. MMDDYY10. DDMMYY10. DATE7. DATE9. MONYY7. QTR. YEAR YYQ4. YYQ6. WORDDATE. WEEKDAY. DOWNAME. WEEKDATE. WORDDATX.
Making Your Own Formats • PROC FORMAT Permanent and TemporaryNew in SAS 9.1 ! • Value and Picture Formats • Informats (not covered in this presentation) • Rules: Formats for character variables start with the dollar sign ($) Format names can be up to32characters long • Including the dollar sign ($) if you are creating a character format • The dollar sign “counts towards the 32 character maximum format length
• More Rules User created FORMATS cannot • have the same names as SAS-supplied formats • end with a number • Common mistakes people make when creating their own Formats Creating a Character Format for a numeric variable or vise-versa Specifying overlapping ranges of values Not including all values in ranges
Using Formats to “Bin or Collapse a Variable • One useful benefit of Formats is avoiding the need to create variables in a data set that are “re-codes of other variables in the data set. • Instead, use a Format! • Example, “bucket grades in to two groups Passed (A,B and C) Failed (D,F)