z*********o 发帖数: 541 | 1 given a few names. which codes should I use to select persons that the
person's first name begins with an N? thank you.
the output such as ,
names
CARAWAY, NEIL
CHAPMAN, NEIL
OVERBY, NADINE
WILDER, NEIL
JONES, NATHAN
TUCKER, NEIL
WELLS, NADINE
SAND | w***z 发帖数: 28 | 2 proc sql;
create table new as
select lastname, firstname
from test
where upcase(firstname) like 'N%';
quit; | z*********o 发帖数: 541 | 3 column的name 是 names,不是last name,first name, run了一下没有output?
【在 w***z 的大作中提到】 : proc sql; : create table new as : select lastname, firstname : from test : where upcase(firstname) like 'N%'; : quit;
| s******r 发帖数: 1524 | 4 proc sql;create table test2 as
select * from test
where index(names,", N")>1 or index(names,",N")>1;run;quit;
【在 z*********o 的大作中提到】 : given a few names. which codes should I use to select persons that the : person's first name begins with an N? thank you. : : the output such as , : names : CARAWAY, NEIL : CHAPMAN, NEIL : OVERBY, NADINE : WILDER, NEIL : JONES, NATHAN
| z*********o 发帖数: 541 | 5 出不来结果 :(
【在 s******r 的大作中提到】 : proc sql;create table test2 as : select * from test : where index(names,", N")>1 or index(names,",N")>1;run;quit;
| p*****s 发帖数: 7 | | z*********o 发帖数: 541 | 7 是的,it works. 刚自己有个地方搞错了,
【在 p*****s 的大作中提到】 : scimitar 的方法work得很好啊。
| w***z 发帖数: 28 | 8 sorry.
using index is a good idea, Scimitar's code should work.
proc sql;
select names
from test1
where scan(upcase(names),2,',') like 'N%';
quit; | z*********o 发帖数: 541 | 9 thank you so much
【在 w***z 的大作中提到】 : sorry. : using index is a good idea, Scimitar's code should work. : proc sql; : select names : from test1 : where scan(upcase(names),2,',') like 'N%'; : quit;
| s******r 发帖数: 1524 | 10 In this case, compress would be necessary to handle space.
proc sql;
select names
from test1
where compress(scan(upcase(names),2,',')) like 'N%';
quit;
【在 w***z 的大作中提到】 : sorry. : using index is a good idea, Scimitar's code should work. : proc sql; : select names : from test1 : where scan(upcase(names),2,',') like 'N%'; : quit;
|
|