首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >列表输入中的tilde、dlm和冒号格式修饰符

列表输入中的tilde、dlm和冒号格式修饰符
EN

Stack Overflow用户
提问于 2015-01-06 06:18:02
回答 1查看 2K关注 0票数 4

有三个概念,我想澄清。:(colon format modifier)~(tilde)dlm=

代码语言:javascript
复制
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

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2015-01-06 06:47:54

  1. 冒号操作符必须告诉SAS使用所提供的informat,但当遇到分隔符时,必须停止读取此变量的值。不要忘记冒号,因为如果没有冒号,SAS可以通过分隔符读取,以满足informat中指定的宽度。

http://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/viewer.htm#a000144370.htm

  1. ~需要以一种特殊的方式处理字符值中的单引号、双引号和分隔符。此格式修饰符将引号字符值中的分隔符读取为字符而不是分隔符,并在将值写入变量时保留引号。

为什么需要,因为SAS为其自身的功能保留了某些分隔符,即单引号,双引号用于表示字符串,当您想要对这些引号进行不同的处理时,必须将其显式地告诉SAS使用- Tilde (~)

http://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/viewer.htm#a000144370.htm

  1. SAS只能自动识别单个blank作为分隔符,也不能自动识别,,因为delimiter.You必须将其显式地告诉SAS。在您的例子中,您使用了选项dsd,它为您做了三件事。

代码语言:javascript
复制
- (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

票数 6
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/27793133

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档