楼主: 围炉吃瓜
47640 17

scan是什么意思呢? [推广有奖]

11
wodematlab 发表于 2015-5-5 21:49:22 |只看作者 |坛友微信交流群
scan一个扫描函数。也可以从后面往前去。

使用道具

Bluewater1111 发表于 2014-1-26 14:38
因为你的scan(title,3,' ,')中,在‘,’的 , 之前有个空格。
scan(title,3,' ,')中,在‘,’的 , 之前有个空格,scan会选择在分割符在前的进行分割,如本例中空格在‘,’之前

使用道具

13
熠熠生辉 发表于 2015-10-27 17:49:10 |只看作者 |坛友微信交流群
【功能】返回字符串S中的第n个单词
【类别】 字符函数
【语法】
1. Scan(s,n) n为正数时,从字符s开始提取第n个单词
2. Scan(s,n) n为负数时,从字符s末尾向前提取第n个单词
3. SCAN (s,n,<list-of-delimiters>)  指定分隔符列表
默认情况下 以常见的分隔符如标点符号、 空格等进行分割

使用道具

14
yanzhoulu 发表于 2017-6-28 12:36:28 |只看作者 |坛友微信交流群
南方科技(000027)变成000027  怎么写啊
stkcd=scan(stknm,,)

使用道具

15
summerwe 发表于 2017-12-29 17:07:37 |只看作者 |坛友微信交流群
zhangzachary 发表于 2012-5-17 16:23
scan [sk&aelig;n]   
vt. 扫描;浏览;细看;详细调查;标出格律
vi. 扫描;扫掠
你是来搞笑的嘛?

使用道具

16
superguy333 发表于 2017-12-29 19:55:18 |只看作者 |坛友微信交流群
yanzhoulu 发表于 2017-6-28 12:36
南方科技(000027)变成000027  怎么写啊
stkcd=scan(stknm,,)
stkcd=scan(stknm,1,‘dko’)

使用道具

17
superguy333 发表于 2017-12-29 20:25:39 |只看作者 |坛友微信交流群
  1. data work.test;
  2. Title = 'A Tale of two Cities, Charles j.Dickens';
  3. Word1 =scan(title, 1 , ',');
  4. Word2 =scan(title, 2 , ',');
  5. Word3 =scan(title, 3 , ',');
  6. Word4 =scan(title, 1 , ' ,');/*以下3个例子均有空格*/
  7. Word5 =scan(title, 2 , ' ,');
  8. Word6 =scan(title, 3 , ' ,');
  9. run;
复制代码



分隔符号‘,’ ( 前面无空格),将字符串title分割成2个单元, 第1个就是 A Tale of two Cities ,第2个就是Charles j.Dickens,第3个不存在,因此为空。
分隔符号‘  ,’ 前面有空格 , 为非常规分隔符,默认为空格,因此第1个就是A ,第2个就是Tale ,第3个就是of。


常见的分割符与PC系统有关:
  1. If you use the SCAN function with only two arguments, then the default delimiters depend on whether your computer uses ASCII or EBCDIC characters.
  2. If your computer uses ASCII characters, then the default delimiters are as follows:
  3. blank ! $ % & ( ) * + , - . / ; < ^ |
  4. In ASCII environments that do not contain the ^ character, the SCAN function uses the ~ character instead.
  5. If your computer uses EBCDIC characters, then the default delimiters are as follows:
  6. blank ! $ % & ( ) * + , - . / ; < ¬ | ¢
  7. If you use the modifier argument without specifying any characters as delimiters, then the only delimiters that will be used are delimiters that are defined by the modifier argument. In this case, the lists of default delimiters for ASCII and EBCDIC environments are not used. In other words, modifiers add to the list of delimiters that are explicitly specified by the charlist argument. Modifiers do not add to the list of default modifiers.
复制代码

SCAN.PNG (4.75 KB)

SCAN.PNG

使用道具

18
zhu6695077 发表于 2020-8-8 09:56:24 |只看作者 |坛友微信交流群
superguy333 发表于 2017-12-29 20:25
分隔符号‘,’ ( 前面无空格),将字符串title分割成2个单元, 第1个就是 A Tale of two Cities ,第 ...
厉害了,谢谢,涨姿势了

使用道具

您需要登录后才可以回帖 登录 | 我要注册

本版微信群
加好友,备注cda
拉您进交流群

京ICP备16021002-2号 京B2-20170662号 京公网安备 11010802022788号 论坛法律顾问:王进律师 知识产权保护声明   免责及隐私声明

GMT+8, 2024-4-25 07:40