Formats tutorial slides for VirtualSUG March  2008
37 pages
English

Formats tutorial slides for VirtualSUG March 2008

-

Le téléchargement nécessite un accès à la bibliothèque YouScribe
Tout savoir sur nos offres
37 pages
English
Le téléchargement nécessite un accès à la bibliothèque YouScribe
Tout savoir sur nos offres

Description

My Friend the®SAS FormatAndrew H. KarpSierra Information Services19229 Sonoma Highway #264Sonoma, California 95476 USA707 996 7380Andrew@sierrainformation.comhttp://www.SierraInformation.com1Copyright © 2005 Sierra Information Services, Inc. All rights reserved. This document may not be duplicated without the express written consent of the copyright holder. SAS and all SAS Institute product names contained herein are trademarks of SAS Institute, Inc. in the USA and other countries (R) indicates USA registration. Revised Feb 2005My Friend the SAS Format• 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 Sets2Copyright © 2005 Sierra Information Services, Inc. All rights reserved. This document may not be duplicated without the express written consent of the copyright holder. SAS and all SAS Institute product names contained herein are trademarks of SAS Institute, Inc. in the USA and other countries (R) indicates USA registration. Revised Feb 20051What Does a SAS Format “do”?• A Format is an instruction that the SAS System uses when portraying, or otherwise using, the ...

Informations

Publié par
Nombre de lectures 59
Langue English

Extrait

My Friend the SAS®taForm AndrewH.Karp
Sierra Information Services 19229 Sonoma Highway #264 Sonoma, California 95476 USA 707 996 7380 Andrew@sierrainformation.com http://www.ierrSormaaInf.itnocom
Copyright © 2005 Sierra Information Services, Inc. All rights reserved. This document may not be duplicated without the express written consent of the copyright holder. SAS and1 all SAS Institute product names contained herein are trademarks of SAS Institute, Inc. in the USA and other countries (R) indicates USA registration. Revised Feb 2005
My Friend the SAS Format
• 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
Copyright © 2005 Sierra Information Services, Inc. All rights reserved. This document may not be duplicated without the express written consent of the copyright holder. SAS and2 all SAS Institute product names contained herein are trademarks of SAS Institute, Inc. in the USA and other countries (R) indicates USA registration. Revised Feb 2005
1
What Does a SAS Format “do”?
• 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
Copyright © 2005 Sierra Information Services, Inc. All rights reserved. This document may not be duplicated without the express written consent of the copyright holder. SAS and3 all SAS Institute product names contained herein are trademarks of SAS Institute, Inc. in the USA and other countries (R) indicates USA registration. Revised Feb 2005
How Do We Use Formats?
• Most SAS Procedures Use the Formatted Values of Variables • Formats are “associated” to variables – In aDataStep • Add Format Associations to the Descriptor Portion of a Data Set When it is Created – In aProcedureStep • Apply Format(s) to Variables(s) When Using a Procedure – UsingPROC DATASETS • Add Format Associations to the Descriptor Portion of an Existing SAS Data Set Copyright © 2005 Sierra Information Services, Inc. All rights reserved. This document may not be duplicated without the express written consent of the copyright holder. SAS and4 all SAS Institute product names contained herein are trademarks of SAS Institute, Inc. in the USA and other countries (R) indicates USA registration. Revised Feb 2005
2
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
Copyright © 2005 Sierra Information Services, Inc. All rights reserved. This document may not be duplicated without the express written consent of the copyright holder. SAS and5 all SAS Institute product names contained herein are trademarks of SAS Institute, Inc. in the USA and other countries (R) indicates USA registration. Revised Feb 2005
A Basic Example
Copyright © 2005 Sierra Information Services, Inc. All rights reserved. This document may not be duplicated without the express written consent of the copyright holder. SAS and6 all SAS Institute product names contained herein are trademarks of SAS Institute, Inc. in the USA and other countries (R) indicates USA registration. Revised Feb 2005
3
A Basic Example
Copyright © 2005 Sierra Information Services, Inc. All rights reserved. This document may not be duplicated without the express written consent of the copyright holder. SAS and7 all SAS Institute product names contained herein are trademarks of SAS Institute, Inc. in the USA and other countries (R) indicates USA registration. Revised Feb 2005
A Basic Example
Copyright © 2005 Sierra Information Services, Inc. All rights reserved. This document may not be duplicated without the express written consent of the copyright holder. SAS and8 all SAS Institute product names contained herein are trademarks of SAS Institute, Inc. in the USA and other countries (R) indicates USA registration. Revised Feb 2005
4
A Basic Example
Copyright © 2005 Sierra Information Services, Inc. All rights reserved. This document may not be duplicated without the express written consent of the copyright holder. SAS and9 all SAS Institute product names contained herein are trademarks of SAS Institute, Inc. in the USA and other countries (R) indicates USA registration. Revised Feb 2005
A Basic Example
Copyright © 2005 Sierra Information Services, Inc. All rights reserved. This document may not be duplicated without the express written consent of the copyright holder. SAS an1d0 all SAS Institute product names contained herein are trademarks of SAS Institute, Inc. in the USA and other countries (R) indicates USA registration. Revised Feb 2005
5
A Basic Example
Copyright © 2005 Sierra Information Services, Inc. All rights reserved. This document may not be duplicated without the express written consent of the copyright holder. SAS an1d1 all SAS Institute product names contained herein are trademarks of SAS Institute, Inc. in the USA and other countries (R) indicates USA registration. Revised Feb 2005
Key Concept
• 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.
Copyright © 2005 Sierra Information Services, Inc. All rights reserved. This document may not be duplicated without the express written consent of the copyright holder. SAS an1d2 all SAS Institute product names contained herein are trademarks of SAS Institute, Inc. in the USA and other countries (R) indicates USA registration. Revised Feb 2005
6
Another Example of Date Formats
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
Copyright © 2005 Sierra Information Services, Inc. All rights reserved. This document may not be duplicated without the express written consent of the copyright holder. SAS an1d4 all SAS Institute product names contained herein are trademarks of SAS Institute, Inc. in the USA and other countries (R) indicates USA registration. Revised Feb 2005
7
Making Your Own Formats
• 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
Copyright © 2005 Sierra Information Services, Inc. All rights reserved. This document may not be duplicated without the express written consent of the copyright holder. SAS an1d5 all SAS Institute product names contained herein are trademarks of SAS Institute, Inc. in the USA and other countries (R) indicates USA registration. Revised Feb 2005
Making Your Own Formats
Copyright © 2005 Sierra Information Services, Inc. All rights reserved. This document may not be duplicated without the express written consent of the copyright holder. SAS an1d6 all SAS Institute product names contained herein are trademarks of SAS Institute, Inc. in the USA and other countries (R) indicates USA registration. Revised Feb 2005
8
Making Your Own Formats
Copyright © 2005 Sierra Information Services, Inc. All rights reserved. This document may not be duplicated without the express written consent of the copyright holder. SAS an1d7 all SAS Institute product names contained herein are trademarks of SAS Institute, Inc. in the USA and other countries (R) indicates USA registration. Revised Feb 2005
Making Your Own Formats
Copyright © 2005 Sierra Information Services, Inc. All rights reserved. This document may not be duplicated without the express written consent of the copyright holder. SAS an1d8 all SAS Institute product names contained herein are trademarks of SAS Institute, Inc. in the USA and other countries (R) indicates USA registration. Revised Feb 2005
9
Making Your Own Formats
Copyright © 2005 Sierra Information Services, Inc. All rights reserved. This document may not be duplicated without the express written consent of the copyright holder. SAS an1d9 all SAS Institute product names contained herein are trademarks of SAS Institute, Inc. in the USA and other countries (R) indicates USA registration. Revised Feb 2005
Making Your Own Formats
Copyright © 2005 Sierra Information Services, Inc. All rights reserved. This document may not be duplicated without the express written consent of the copyright holder. SAS an2d0 all SAS Institute product names contained herein are trademarks of SAS Institute, Inc. in the USA and other countries (R) indicates USA registration. Revised Feb 2005
10
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)
Copyright © 2005 Sierra Information Services, Inc. All rights reserved. This document may not be duplicated without the express written consent of the copyright holder. SAS an2d1 all SAS Institute product names contained herein are trademarks of SAS Institute, Inc. in the USA and other countries (R) indicates USA registration. Revised Feb 2005
Making Your Own Formats
Copyright © 2005 Sierra Information Services, Inc. All rights reserved. This document may not be duplicated without the express written consent of the copyright holder. SAS an2d2 all SAS Institute product names contained herein are trademarks of SAS Institute, Inc. in the USA and other countries (R) indicates USA registration. Revised Feb 2005
11
  • Univers Univers
  • Ebooks Ebooks
  • Livres audio Livres audio
  • Presse Presse
  • Podcasts Podcasts
  • BD BD
  • Documents Documents