SAS——proc format的其他应用:invalue,picture,default,mult,prefix,noedit,_same_,_error_,other

一、

proc format;

invalue $test (default=200)

"1"=_same_

"2"="Black"

"3"="Asian"

"4","5","6"="other"

other=_error_;

run;

 

1.invalue也可以用来定义字符型格式

2.default的用法与length同

3._same_表示将其保持原来格式

4._error_表示将其他未列出的值都设为空值

5.可以用逗号分隔多种原始值,转换成同一种输出格式

 

二、

proc format ;

picture one

low-high='009.0%' (mult=1000);

run;

 

1.picture statement

2.low-high 针对所有数字

3.(mult=1000)原数字乘以1000

4.展示为009.0%这种形式,前面的0可根据实际情况去掉或者保留为原值或者去掉,小数点后的0保证显示为一位小数。如果是000.0%,原数据为0format之后为空,如果是009.0%format之后为0.0%,如果是000.9%format之后是0%也就是说如果是9则一定会显示出这一位,如果是前面的0则根据实际情况显示。

 

计算机生成了可选文字:
-procformat
PictureOne
low—high='009.0,
(皿ult=1000);
-dataa;
a=0:Output:
a—I
:Output:
a—O·03;output:
a—I·1:output:
a—O·12121:output:
-datad;
Set
a:
b=put()'one·

 

计算机生成了可选文字:
2
3
4
5
b
0
11閬.0
003
3£
1.11100
012121
121

 

三、

proc format ;

picture two (round default=10)

0="0"(noedit)

100="(100)"(noedit)

0.00000001-<10="009.9)"(prefix="( ")

10-<100="099.9)"(prefix="(")

100<-9999999999999999999="009.9)"(prefix="!!(");

run;

1.noedit保持原输出格式不动,如果不加,0会显示为空

2.prefix是添加前缀的选项,因为不确定数字的长度,为保证(11.1)的对齐形式,如果原数据是1.1,则应该在输出格式前面加上前括号和一个空格,如果是11.1则不需要添加多一个括号。

3.不能有overlap的情况,即范围重叠,可使用<或不用符号来表示小于或小于等于。

猜你喜欢

转载自www.cnblogs.com/jwcutey/p/12052393.html
今日推荐