- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Posted 05-28-2019 10:16 AM
(1500 views)
data one;
input decode $10.;
datalines;
aaaa
bbbb
cccc
eeee
;
data cm;
input decode $1-14;
datalines;
aaaa a1b1 ew22
vfdf bbbb b1w2
eewe cccc c2c2
dddd de33 eewe
;
Dear,
I have to create a dataset by merging two data sets by decode variable. The output should contain records from cm data set if the values from Cm contains the values in one dataset.
From the above input, output should not contain "dddd de33 eewe
" as this value 'dddd' not in data one.
Please suggest. Thank you
output;
decode aaaa a1b1 ew22
vfdf bbbb b1w2
eewe cccc c2c2
3 REPLIES 3
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
PROC SQL;
CREATE TABLE want AS
SELECT a.*
FROM CM a
INNER JOIN one b
ON index(strip(a.decode),strip(b.decode))
;
QUIT;
________________________
- Cheers -
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
You could use a contains clause
proc sql;
select *
from cm
where exists (select decode from one where cm.decode contains strip(decode));
quit;
But if you are looking for words, it might be better to use FINDW which does specifically that:
proc sql;
select *
from cm
where exists (select * from one where findw(cm.decode, strip(decode)) > 0);
quit;
PG
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
data one;
input decode $10.;
datalines;
aaaa
bbbb
cccc
eeee
;
data cm;
input decode $1-14;
datalines;
aaaa a1b1 ew22
vfdf bbbb b1w2
eewe cccc c2c2
dddd de33 eewe
;
proc sql;
select cm.decode
from one,cm
where cm.decode contains strip(one.decode);
quit;