求助各位大侠
问题:
x,y分别是两个变量,字符型
现在我想看x中是否含有y这个字符串,含的话赋值c=y否则c=0
我的程序如下:
if index(x,y)>0 then c=y;
else c=0;
可是结果总是显示c=0
请问大侠这是什么原因,谢谢

|
楼主: waxinigou
|
32038
7
求助index函数的使用 |
|
初中生 66%
-
|
回帖推荐SignPingGu 发表于4楼 查看完整内容 If your code is working inside Data step, and X, Y are variable of the dataset you are working with, then the code will be fine.But if your code is working inside Data step, and neither X or Y is the variable of the dataset you are working with, then SAS will treat X, Y as two new variables without iniitalization. The code will run as you have stated, just make C = 0 all the way. If you run t ...
Samples from SAS.comFor these examples STRING = "ABCDEFG"Code ReturnINDEX(STRING,'C') 3 (the position of the 'C')INDEX(STRING,'DEF') 4 (the position of the 'D')INDEX(STRING,'X') 0 (no "X" in the string)INDEX(STRING,'ACE') 0 (no "ACE" in the string)It looks your code is OK. The following code may help to solve ...
本帖被以下文库推荐
| ||
|
|
| ||
| ||
| ||
加好友,备注cda京ICP备16021002号-2 京B2-20170662号
京公网安备 11010802022788号
论坛法律顾问:王进律师
知识产权保护声明
免责及隐私声明


