©Spring 2012 Imelda Go, John Grego, Jennifer Lasecki and the University of South Carolina Chapter...
-
Upload
gloria-garrett -
Category
Documents
-
view
217 -
download
0
Transcript of ©Spring 2012 Imelda Go, John Grego, Jennifer Lasecki and the University of South Carolina Chapter...
![Page 1: ©Spring 2012 Imelda Go, John Grego, Jennifer Lasecki and the University of South Carolina Chapter 17 supplement: Review of Formatting Data STAT 541.](https://reader035.fdocuments.net/reader035/viewer/2022062408/56649e9e5503460f94ba02e9/html5/thumbnails/1.jpg)
©Spring 2012 Imelda Go, John Grego, Jennifer Lasecki and the University of South Carolina
Chapter 17 supplement:
Review of Formatting
Data
STAT 541
![Page 2: ©Spring 2012 Imelda Go, John Grego, Jennifer Lasecki and the University of South Carolina Chapter 17 supplement: Review of Formatting Data STAT 541.](https://reader035.fdocuments.net/reader035/viewer/2022062408/56649e9e5503460f94ba02e9/html5/thumbnails/2.jpg)
Informats
(input-related)how to read data values
CONVERT[interpretation]
Formats(output-related)how to write data values
PRINT[appearance]
are
instructions
![Page 3: ©Spring 2012 Imelda Go, John Grego, Jennifer Lasecki and the University of South Carolina Chapter 17 supplement: Review of Formatting Data STAT 541.](https://reader035.fdocuments.net/reader035/viewer/2022062408/56649e9e5503460f94ba02e9/html5/thumbnails/3.jpg)
Standard
examples:2.1$5.
$char5.yymmdd8.
User-Defined
PROC FORMAT
Formats and
Informats
![Page 4: ©Spring 2012 Imelda Go, John Grego, Jennifer Lasecki and the University of South Carolina Chapter 17 supplement: Review of Formatting Data STAT 541.](https://reader035.fdocuments.net/reader035/viewer/2022062408/56649e9e5503460f94ba02e9/html5/thumbnails/4.jpg)
original values: 00 10 15 20 25 30 35 40
desired values: 0.0 1.0 1.5 2.0 2.5 3.0 3.5 4.0
Standard Informat for Input
![Page 5: ©Spring 2012 Imelda Go, John Grego, Jennifer Lasecki and the University of South Carolina Chapter 17 supplement: Review of Formatting Data STAT 541.](https://reader035.fdocuments.net/reader035/viewer/2022062408/56649e9e5503460f94ba02e9/html5/thumbnails/5.jpg)
Standard Informat for Input
![Page 6: ©Spring 2012 Imelda Go, John Grego, Jennifer Lasecki and the University of South Carolina Chapter 17 supplement: Review of Formatting Data STAT 541.](https://reader035.fdocuments.net/reader035/viewer/2022062408/56649e9e5503460f94ba02e9/html5/thumbnails/6.jpg)
Standard Informat for Fixed-Width Input
![Page 7: ©Spring 2012 Imelda Go, John Grego, Jennifer Lasecki and the University of South Carolina Chapter 17 supplement: Review of Formatting Data STAT 541.](https://reader035.fdocuments.net/reader035/viewer/2022062408/56649e9e5503460f94ba02e9/html5/thumbnails/7.jpg)
Standard Informat for Delimited InputThe : argument indicates length
is up to 19 characters.
with the LENGTH statement
![Page 8: ©Spring 2012 Imelda Go, John Grego, Jennifer Lasecki and the University of South Carolina Chapter 17 supplement: Review of Formatting Data STAT 541.](https://reader035.fdocuments.net/reader035/viewer/2022062408/56649e9e5503460f94ba02e9/html5/thumbnails/8.jpg)
Character
Begins with $
INFORMAT
+ up to 30 charactersFORMAT
+ up to 31 characters
NumericINFORMAT
Up to 31 characters
FORMATUp to 32 characters
Naming Conventions for User-Defined Formats (VALUE, PICTURE) and
Informats (INVALUE) in PROC FORMAT
Use valid SAS names that do not end in a number.
VALID
$gender
$gender2F
INVALID
$gender2
$2gender
VALID
gender
gender2F
INVALID
gender2
2gender
In SAS code, refer to them with a period following their name, BUT do not use the period in PROC FORMAT.
![Page 9: ©Spring 2012 Imelda Go, John Grego, Jennifer Lasecki and the University of South Carolina Chapter 17 supplement: Review of Formatting Data STAT 541.](https://reader035.fdocuments.net/reader035/viewer/2022062408/56649e9e5503460f94ba02e9/html5/thumbnails/9.jpg)
User-Defined Informat for Input
![Page 10: ©Spring 2012 Imelda Go, John Grego, Jennifer Lasecki and the University of South Carolina Chapter 17 supplement: Review of Formatting Data STAT 541.](https://reader035.fdocuments.net/reader035/viewer/2022062408/56649e9e5503460f94ba02e9/html5/thumbnails/10.jpg)
Data Validation with Informats
![Page 11: ©Spring 2012 Imelda Go, John Grego, Jennifer Lasecki and the University of South Carolina Chapter 17 supplement: Review of Formatting Data STAT 541.](https://reader035.fdocuments.net/reader035/viewer/2022062408/56649e9e5503460f94ba02e9/html5/thumbnails/11.jpg)
Standard and User-Defined Formats for Output
Appearance of Numbers in Output
![Page 12: ©Spring 2012 Imelda Go, John Grego, Jennifer Lasecki and the University of South Carolina Chapter 17 supplement: Review of Formatting Data STAT 541.](https://reader035.fdocuments.net/reader035/viewer/2022062408/56649e9e5503460f94ba02e9/html5/thumbnails/12.jpg)
Why are formats and informats useful for SAS date variables?
![Page 13: ©Spring 2012 Imelda Go, John Grego, Jennifer Lasecki and the University of South Carolina Chapter 17 supplement: Review of Formatting Data STAT 541.](https://reader035.fdocuments.net/reader035/viewer/2022062408/56649e9e5503460f94ba02e9/html5/thumbnails/13.jpg)
Date type an integer equal to the number of days elapsed since Jan. 1, 1960
Date SAS Date Value
Dec. 31, 1959 -1
Jan. 1, 1960 0
Jan. 2, 1960 1
Jan. 10, 1960 9
![Page 14: ©Spring 2012 Imelda Go, John Grego, Jennifer Lasecki and the University of South Carolina Chapter 17 supplement: Review of Formatting Data STAT 541.](https://reader035.fdocuments.net/reader035/viewer/2022062408/56649e9e5503460f94ba02e9/html5/thumbnails/14.jpg)
Appearance of SAS Dates (Numbers) in Output
![Page 15: ©Spring 2012 Imelda Go, John Grego, Jennifer Lasecki and the University of South Carolina Chapter 17 supplement: Review of Formatting Data STAT 541.](https://reader035.fdocuments.net/reader035/viewer/2022062408/56649e9e5503460f94ba02e9/html5/thumbnails/15.jpg)
Appearance of Numbers in Output
![Page 16: ©Spring 2012 Imelda Go, John Grego, Jennifer Lasecki and the University of South Carolina Chapter 17 supplement: Review of Formatting Data STAT 541.](https://reader035.fdocuments.net/reader035/viewer/2022062408/56649e9e5503460f94ba02e9/html5/thumbnails/16.jpg)
Formats for Output: Just a PROC
![Page 17: ©Spring 2012 Imelda Go, John Grego, Jennifer Lasecki and the University of South Carolina Chapter 17 supplement: Review of Formatting Data STAT 541.](https://reader035.fdocuments.net/reader035/viewer/2022062408/56649e9e5503460f94ba02e9/html5/thumbnails/17.jpg)
Formats for Output: Many PROCs
![Page 18: ©Spring 2012 Imelda Go, John Grego, Jennifer Lasecki and the University of South Carolina Chapter 17 supplement: Review of Formatting Data STAT 541.](https://reader035.fdocuments.net/reader035/viewer/2022062408/56649e9e5503460f94ba02e9/html5/thumbnails/18.jpg)
A numeric missing value in SAS means there is no data value. Missing Value Type Representation Description
RegularNumeric . Single period
SpecialNumeric
.a
.b
.c.
.
.
.x
.y
.z
Single period followed by a letter
These are not case-sensitive. (.A is equivalent to .a).
SpecialNumeric ._ Single period followed by an underscore
Numeric Missing Values
![Page 19: ©Spring 2012 Imelda Go, John Grego, Jennifer Lasecki and the University of South Carolina Chapter 17 supplement: Review of Formatting Data STAT 541.](https://reader035.fdocuments.net/reader035/viewer/2022062408/56649e9e5503460f94ba02e9/html5/thumbnails/19.jpg)
Meaning of Special Numeric Missing Values
![Page 20: ©Spring 2012 Imelda Go, John Grego, Jennifer Lasecki and the University of South Carolina Chapter 17 supplement: Review of Formatting Data STAT 541.](https://reader035.fdocuments.net/reader035/viewer/2022062408/56649e9e5503460f94ba02e9/html5/thumbnails/20.jpg)
Format for Group Processing
![Page 21: ©Spring 2012 Imelda Go, John Grego, Jennifer Lasecki and the University of South Carolina Chapter 17 supplement: Review of Formatting Data STAT 541.](https://reader035.fdocuments.net/reader035/viewer/2022062408/56649e9e5503460f94ba02e9/html5/thumbnails/21.jpg)
Create new variables from existing ones (recode)with PUTand INPUTfunctions
![Page 22: ©Spring 2012 Imelda Go, John Grego, Jennifer Lasecki and the University of South Carolina Chapter 17 supplement: Review of Formatting Data STAT 541.](https://reader035.fdocuments.net/reader035/viewer/2022062408/56649e9e5503460f94ba02e9/html5/thumbnails/22.jpg)
General syntax without optional arguments:PUT(source,format)
Always returns a character value by applying a format to an expression (source)
Converts numeric to character values
The format must be of the same type as source.
PUT Function and Format
![Page 23: ©Spring 2012 Imelda Go, John Grego, Jennifer Lasecki and the University of South Carolina Chapter 17 supplement: Review of Formatting Data STAT 541.](https://reader035.fdocuments.net/reader035/viewer/2022062408/56649e9e5503460f94ba02e9/html5/thumbnails/23.jpg)
General syntax without optional arguments:
INPUT(source,informat)
Returns a value by applying an informat to an expression (source)
Informat type determines numeric or character type result.
Converts character to numeric values
INPUT Function and Informat
![Page 24: ©Spring 2012 Imelda Go, John Grego, Jennifer Lasecki and the University of South Carolina Chapter 17 supplement: Review of Formatting Data STAT 541.](https://reader035.fdocuments.net/reader035/viewer/2022062408/56649e9e5503460f94ba02e9/html5/thumbnails/24.jpg)
Array Index Values are Easier to Follow
![Page 25: ©Spring 2012 Imelda Go, John Grego, Jennifer Lasecki and the University of South Carolina Chapter 17 supplement: Review of Formatting Data STAT 541.](https://reader035.fdocuments.net/reader035/viewer/2022062408/56649e9e5503460f94ba02e9/html5/thumbnails/25.jpg)
LOOKUP TABLES
![Page 26: ©Spring 2012 Imelda Go, John Grego, Jennifer Lasecki and the University of South Carolina Chapter 17 supplement: Review of Formatting Data STAT 541.](https://reader035.fdocuments.net/reader035/viewer/2022062408/56649e9e5503460f94ba02e9/html5/thumbnails/26.jpg)
Q: What do I do if there’s A LOT to type??
A: If the information is in a data set, you can create the format automatically.
![Page 27: ©Spring 2012 Imelda Go, John Grego, Jennifer Lasecki and the University of South Carolina Chapter 17 supplement: Review of Formatting Data STAT 541.](https://reader035.fdocuments.net/reader035/viewer/2022062408/56649e9e5503460f94ba02e9/html5/thumbnails/27.jpg)
INPUT CONTROL DATA SETS (CNTLIN=)
TYPE:C for Character FORMATN for Numeric FORMATI for Numeric INFORMATJ for Character INFORMAT
![Page 28: ©Spring 2012 Imelda Go, John Grego, Jennifer Lasecki and the University of South Carolina Chapter 17 supplement: Review of Formatting Data STAT 541.](https://reader035.fdocuments.net/reader035/viewer/2022062408/56649e9e5503460f94ba02e9/html5/thumbnails/28.jpg)
OUTPUT CONTROL DATA SETS (CNTLOUT=)
![Page 29: ©Spring 2012 Imelda Go, John Grego, Jennifer Lasecki and the University of South Carolina Chapter 17 supplement: Review of Formatting Data STAT 541.](https://reader035.fdocuments.net/reader035/viewer/2022062408/56649e9e5503460f94ba02e9/html5/thumbnails/29.jpg)
PROC CONTENTS labels describe variables in output control data sets.
![Page 30: ©Spring 2012 Imelda Go, John Grego, Jennifer Lasecki and the University of South Carolina Chapter 17 supplement: Review of Formatting Data STAT 541.](https://reader035.fdocuments.net/reader035/viewer/2022062408/56649e9e5503460f94ba02e9/html5/thumbnails/30.jpg)
User-defined formats can be stored in format catalogs and accessed
later.
Later:
PC SASExample
![Page 31: ©Spring 2012 Imelda Go, John Grego, Jennifer Lasecki and the University of South Carolina Chapter 17 supplement: Review of Formatting Data STAT 541.](https://reader035.fdocuments.net/reader035/viewer/2022062408/56649e9e5503460f94ba02e9/html5/thumbnails/31.jpg)
NESTED FORMATS