joskow 发表于 2010-1-7 15:00 
当list input读入非标准数值或长于8字符的字符变量时,需要加:
那么,下面两个程序,为什么一个必须加:而另一个不需要。
data test;
input country $8. date mmddyy10.;
cards;
Germany 12/31/2000
France 01/31/2001
;
run;
1---+----10---+----20---+---
son Frank 01/31/89
daughter June 12-25-87
brother Samuel 01/17/51
data work.family;
infile 'file-specification';
input relation $ first_name $ birthdate : mmddyy8.;
run;
There is a couple of knowledge points here.
1)An informat not only tells SAS how many positions should be read in but also inplies/defines variable length for a char variable. 2)The column modifier has a special input instruction. Here is its definition in this case.
Usually (:) the column modifier is needed for a variable-length record/observation when one also uses informats on an input statement.
:
enables you to specify an informat that the INPUT statement uses to read the variable value. For a character variable, this format modifier reads the value from the next non-blank column until the pointer reaches the next blank column, the defined length of the variable, or the end of the data line, whichever comes first. For a numeric variable, this format modifier reads the value from the next non-blank column until the pointer reaches the next blank column or the end of the data line, whichever comes first.