m*******g 发帖数: 3044 | 1 例如这句
if substr(measuretitle,12,45) = 'long-stay residents whose need for help
with ' then qi_num = 4;
我的数据里有一个VARIABLE 是measuretitle
如果measuretitle里有两个TITLE是这样
1.long-stay residents assessed and given, appropriately, the pneumococcal
vaccine.
2.long-stay residents assessed and given, appropriately, the seasonal
influenza vaccine.
这两句应该咋写CODE. 前几个单词是一样的,只是后几个不一样. | c***z 发帖数: 6348 | | m*******g 发帖数: 3044 | 3 ........
我想问 substr(measuretitle,12,45)里怎么写?还是(12,45)?如果写
if substr(measuretitle,12,45) = 'long-stay residents assessed and given,
appropriately, the pneumococcal vaccine.' then qi_num = 4;
if substr(measuretitle,12,45) = 'long-stay residents assessed and given,
appropriately, the seasonal influenza vaccine.' then qi_num = 5;
出来的值是一样的.... | t******e 发帖数: 16 | 4 substr(measuretitle,12,45)是取measuretitle里面从12位到45位一共45-12+1=34位字
符,根本不可能等于'long-stay residents assessed and given,appropriately, the
pneumococcal vaccine.'这么一长串东东,所以两个if statement的判断都为否
如果,你问的是R里面的substr的话 :p
【在 m*******g 的大作中提到】 : ........ : 我想问 substr(measuretitle,12,45)里怎么写?还是(12,45)?如果写 : if substr(measuretitle,12,45) = 'long-stay residents assessed and given, : appropriately, the pneumococcal vaccine.' then qi_num = 4; : if substr(measuretitle,12,45) = 'long-stay residents assessed and given, : appropriately, the seasonal influenza vaccine.' then qi_num = 5; : 出来的值是一样的....
| m*******g 发帖数: 3044 | | m*******g 发帖数: 3044 | 6 一个VAR 是BIRTHDAY, 数值是750603
bdm=substr(birthday,3,2)*1返回的值是6.
WHY?
不应该是06吗?
substr(birthday,3,2)是指从第三位开始数两位? | A*****a 发帖数: 1091 | 7 这不乘以1了么,直接把字符变成数值形式了
【在 m*******g 的大作中提到】 : 一个VAR 是BIRTHDAY, 数值是750603 : bdm=substr(birthday,3,2)*1返回的值是6. : WHY? : 不应该是06吗? : substr(birthday,3,2)是指从第三位开始数两位?
| m*******g 发帖数: 3044 | 8 谢, 再问怎么把字符变成数值形式?
VARIABLE 的名字是SCORE, 里边的数字都是字符型.
【在 A*****a 的大作中提到】 : 这不乘以1了么,直接把字符变成数值形式了
| A*****a 发帖数: 1091 | 9 我记得没法直接变,新建一个来变,比如
score1=score*1;
drop score;
rename score1=score;
【在 m*******g 的大作中提到】 : 谢, 再问怎么把字符变成数值形式? : VARIABLE 的名字是SCORE, 里边的数字都是字符型.
|
|