有三个概念,我想澄清。:(colon format modifier)、~(tilde)和dlm=
data scores;
infile datalines dsd;
input name : $10. score1-score3 team ~ $25. div $;
datalines;
Smith,12,22,46,"Green Hornets, Atlanta",AAA
FriedmanLi,23,19,25,"High Volts, Portland",AAA
Jones,09,17,54,"Vulcans, Las Vegas",AA
;
run;首先,在输入语句中使用:可以完全取代length语句;为什么我不需要:作为团队变量,比如team : ~ $25.?
其次,为什么sas可以自动重新定位,是分隔符,而不是"或blank?
发布于 2015-01-06 06:47:54
http://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/viewer.htm#a000144370.htm
~需要以一种特殊的方式处理字符值中的单引号、双引号和分隔符。此格式修饰符将引号字符值中的分隔符读取为字符而不是分隔符,并在将值写入变量时保留引号。为什么需要,因为SAS为其自身的功能保留了某些分隔符,即单引号,双引号用于表示字符串,当您想要对这些引号进行不同的处理时,必须将其显式地告诉SAS使用- Tilde (~)
http://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/viewer.htm#a000144370.htm
blank作为分隔符,也不能自动识别,,因为delimiter.You必须将其显式地告诉SAS。在您的例子中,您使用了选项dsd,它为您做了三件事。- (i) It automatically by default take `,` as your delimiter. If you want to provide any other delimiter, you would have to specifically tell it to SAS then using `dlm=` option.
- (ii) SAS treats two consecutive delimiters as a missing value and removes quotation marks from character values
- (iii)specifies that when data values are enclosed in quotation marks, delimiters within the value are treated as character data
http://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/viewer.htm#a000146932.htm
https://stackoverflow.com/questions/27793133
复制相似问题