在sas中更改列的长度格式

在sas中更改列的长度格式,sas,create-table,Sas,Create Table,这是我的代码: data want ; input branch_id branch_name $ branch_specification $ bold_type $ bold_score $ ; DATALINES ; 612 NATANYA masham_atirey masham 1.15 ; run ; 分支_规范的输出为masham_a 我希望延长长度。您可以在数据语句下添加length语句 length branch_specificatio

这是我的代码:

data want ; 
    input branch_id branch_name $ branch_specification $ bold_type $ bold_score $ ;
    DATALINES ;
    612 NATANYA masham_atirey  masham 1.15
    ;
run ; 
分支_规范的输出为masham_a
我希望延长长度。

您可以在数据语句下添加
length
语句

length branch_specification $15.;
请记住,length语句将把被操纵的变量放在数据集的前面。您可以使用
retain
语句更改顺序

data want ; 
    retain branch_id branch_name branch_specification;
    length branch_specification $15.;
    input branch_id branch_name $ branch_specification $ bold_type $ bold_score $ ;
    DATALINES ;
    612 NATANYA masham_atirey  masham 1.15
    ;
run ; 

您可以使用
$15.
信息输入
分支机构规范
,其余部分使用列表输入,例如:

data want ; 
    input branch_id branch_name $ branch_specification :$15. bold_type $ bold_score $ ;
    DATALINES ;
612 NATANYA masham_atirey  masham 1.15
;
run ;
这样,您就不需要单独的长度语句,并且变量顺序不变


添加
修饰符可防止输入语句读取超过第一个分隔符(默认为空格)如果
branch\u specification
长度小于15个字符,则输入下一个变量。

为了确保特定的所需PDV,请在其他语句(如
INPUT
ARRAY
)中引用任何变量之前,使用
ATTRIB
语句指定每个变量的元数据属性,计算的LHS,或在函数调用或例程调用中使用。如果值小于15字节,则使用格式化输入读取一个变量可能会导致问题。最好包括
修饰符,以便使用列表模式输入读取变量,就像其他变量一样。创建单个表时,属性数据正常(4到20位之间)。当我使用PROC SQL和UNION ALL时,属性列长度更改为至少4。。。。