程序代写代做代考 MET MA 603: SAS Programming and Applications

MET MA 603: SAS Programming and Applications

MET MA 603:
SAS Programming and Applications

Format Statement

1

1

Format Statement
The Format Statement specifies how SAS will display the variables in a dataset. Formatting is done for visual purpose only – Formats do not impact the underlying data.
Character and Numeric data can both be formatted. Character formats begin with a dollar sign.
Dates are almost always formatted, because otherwise it would be very difficult to determine what is in the data.
The number after the format indicates the maximum number of characters to display.
Formats must include a period so that SAS can distinguish them from variable names.
Example of Format Statement:
format State $Upcase2. Population comma12.0 ;

2

2

Examples of Formats
Character
$w. $CHARw. $UPCASEw.
Date and Time
DATEw. MMDDYYw. YYQRw.
Numeric
w.d COMMAw.d $DOLLARw.d
PERCENTw. PERCENTNw.

3

3

Practice
Use a Data Step to import scores1.txt. Include a Format statement that does the following.:
Display LastName in upper case (e.g., BROWN)
Display Score showing one decimal place (e.g., 77.0)

Why do you think periods are required when using the Format statement, but not with the Length statement?

4

4

Readings

Textbook sections 4.6, 4.7

5

5

/docProps/thumbnail.jpeg