t**********r 发帖数: 182 | 1 first find a word "Masters" in a paragraph;
then if there is a "statistics" 20 space before or 20 space after "Master",
create a dummy variable Master_stat = 1.
Can anybody help me with the SAS code???
thanks. |
D******n 发帖数: 2836 | 2 what is 20 spaces before? |
l***a 发帖数: 12410 | 3 I assume you already store the text as a variable x in a data set a.
data a;
set a;
y=index('MASTERS',upcase(x));
z=substr(a, y-20, y+27);
w=index('STATISTICS',upcase(z));
if w>0 then master_stat=1;
drop y z w;
run;
,
【在 t**********r 的大作中提到】 : first find a word "Masters" in a paragraph; : then if there is a "statistics" 20 space before or 20 space after "Master", : create a dummy variable Master_stat = 1. : Can anybody help me with the SAS code??? : thanks.
|
s******y 发帖数: 352 | 4 this is where Regx come in handy.
data test;
infile cards truncover;
input text $150.;
Master_stat=^^prxmatch('/(?<=statistics\s{20})Masters|Masters(?=\s{20}
statistics)/io',text);
cards;
The department of statistics Masters
The department of statistics Masters
masters statistics sucks
;
run;
proc print;
run; |
s*********k 发帖数: 1989 | 5 nice, regular expression. Easy for PERL person.
Tough for newbie.
【在 s******y 的大作中提到】 : this is where Regx come in handy. : data test; : infile cards truncover; : input text $150.; : Master_stat=^^prxmatch('/(?<=statistics\s{20})Masters|Masters(?=\s{20} : statistics)/io',text); : cards; : The department of statistics Masters : The department of statistics Masters : masters statistics sucks
|
t**********r 发帖数: 182 | |