列表输入中的波浪号、dlm 和冒号格式修饰符 [英] tilde, dlm and colon format modifier in list input

查看:72
本文介绍了列表输入中的波浪号、dlm 和冒号格式修饰符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想澄清 3 个概念.:(冒号格式修饰符)~(波浪号)dlm=

There are 3 concepts i would like to clarify. :(colon format modifier), ~(tilde) and 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. ?

Firstly, usage of : in input statement can totally replace length statement? And why i do not need : for team variable sth like team : ~ $25. ?

其次,为什么sas可​​以自动识别是分隔符而不是"blank?

Secondly, why sas can automatically recoginize , is the delimiter but not " or blank ?

推荐答案

  1. 需要冒号运算符告诉 SAS 使用提供的信息,但在遇到分隔符时停止读取此变量的值.不要忘记冒号,因为没有它们,SAS 可能会读取一个分隔符以满足信息中指定的宽度.
  1. Colon Operator is required to tell SAS to use the informat supplied but to stop reading the value for this variable when a delimiter is encountered. Do not forget the colons because without them SAS may read past a delimiter to satisfy the width specified in the informat.

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

  1. ~ 波浪号是必需的以特殊方式处理字符值中的单引号、双引号和定界符.此格式修饰符将带引号的字符值中的分隔符读取为字符而不是分隔符,并在将值写入变量时保留引号.
  1. ~ Tilde is required to to treat single quotation marks, double quotation marks, and delimiters in character values in a special way. This format modifier reads delimiters within quoted character values as characters instead of as delimiters and retains the quotation marks when the value is written to a variable.

为什么需要这个,因为 SAS 为它自己的功能保留了某些分隔符,即单引号,双引号用于表示字符串,当您希望 SAS 以不同的方式对待这些引号时,您必须使用 - Tilde (~)

Why this is needed, because SAS has reserved certain delimiters for it's own functioning i.e. single quotation marks, double quotation marks are used to represent strings, when you want SAS to treat these quotation marks differently you have to tell explicitly it to SAS using - Tilde (~)

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

  1. SAS 只能自动识别单个 blank 为分隔符,不能自动识别 , 为分隔符.您必须明确告诉 SAS.在您的情况下,您使用了选项 dsd 为您做三件事.

  1. SAS can only automatically recognize single blank as delimiter and it cannot automatically recognize , as delimiter.You would have to explicitly tell it to SAS. In your case you have used the option dsd which does three things for you.

  • (i)默认情况下,它会自动将 , 作为分隔符.如果您想提供任何其他分隔符,您必须明确告诉 SAS,然后使用 dlm= 选项.

  • (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 将两个连续的分隔符视为缺失值并去除字符值中的引号

(ii) SAS treats two consecutive delimiters as a missing value and removes quotation marks from character values

(iii)指定当数据值用引号引起来时,值内的分隔符被视为字符数据

(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

这篇关于列表输入中的波浪号、dlm 和冒号格式修饰符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆