May 26, 2021 SAS
SAS can handle a variety of digital data formats. I t uses these formats at the end of the variable name to apply a specific number format to the data. S AS uses two numeric formats. O ne is used to read a specific format for digital data, called informat, and the other is used to display digital data in a specific format called an output format.
The syntax of digital information is:
Varname Formatnamew.d
The following is a description of the parameters used:
Below is a list of formats used to read data into SAS.
Format | Use |
---|---|
N.
|
The maximum "n" number of columns without a few points. |
n.p
|
The maximum number of columns with "n" and "p" dosdles. |
COMMAn.p | COMMAn.p Max "n" columns with "p" places, remove any commas or dollar signs. |
COMMAn.p | COMMAn.p Max "n" columns with "p" places, remove any commas or dollar signs. |
Similar to applying formats when reading data, the following is a list of formats used to display data in the output of the SAS program.
N.
|
Write the maximum "n" digits without a scale. |
n.p
|
Write the maximum number of columns with a "p" dosdle of "n.p". |
DOLLARn.p
|
Write the maximum "n" column with the p decimal place, preceded by the dollar sign, and use a comma at the thousandth position. |
Please note:
The following example illustrates the above.
DATA MYDATA1; input x 6.; /*数据的最大宽度*/ format x 6.3; datalines; 8722 93.2 .1122 15.116 PROC PRINT DATA = MYDATA1; RUN; DATA MYDATA2; input x 6.; /*数据的最大宽度*/ format x 5.2; datalines; 8722 93.2 .1122 15.116 PROC PRINT DATA=MYDATA2; RUN; DATA MYDATA3; input x 6.; /*数据的最大宽度*/ format x DOLLAR10.2; datalines; 8722 93.2 .1122 15.116 PROC PRINT DATA=MYDATA3; RUN;
When we execute the code above, it produces the following results:
# MYDATA1. Obs x 1 8722.0 # 显示6个十进制后附加零的列。 2 93.200 # 显示6个小数后附加零的列。 3 0.112 # 十进制之前没有整数,因此在十进制后显示3个可用数字。 4 15.116 # 显示6个十进制后有3位可用数字的列。 # MYDATA2 Obs x 1 8722 # 显示5列。 只有4个可用。 2 93.20 # 显示5个十进制后附加零的列。 3 0.11 # 显示5个小数点后2位的列。 4 15.12 # 显示5个小数点后2位的列。 # MYDATA3 Obs x 1 $8,722.00 # 显示10列带有$符号,逗号在第千个位置,零在十进制后附加。 2 $93.20 # 只有两个整数在十进制之前可用,一个可用在十进制之后。 3 $0.11 # 十进制之前没有整数,十进制后有两个可用。 4 $15.12 # 只有两个整数在十进制之前可用,两个可用在十进制之后。