Hello,
I need a help matching columns. Column A and B has names, I want to match names in Column B. If column B name matches with Column A (any order or any part is fine from Col A), need to create a flag with Y or N. Column B name must match exactly with Column A . I tried with SCAN function and few other functions. Proc sql also will work for me. Column A has 1- 6 names. Column B has 1-4 names.
Data Have
Column A Column B
CAMACHO ANAYA FAIBER ANAYA
EVER ANDRES NAVARRO Navas MELO Navarro Navas
EVER ANDRES NAVARRO MELO Navarro Navas
PINILLA AGUDELO JOVANNY PINIL
PINILLA AGUDELO JOVANNY PINILLA
Data Want
Column A Column B Flag
CAMACHO ANAYA FAIBER ANAYA Y
EVER ANDRES NAVARRO Navas MELO Navarro Navas Y
EVER ANDRES NAVARRO MELO Navarro Navas N
PINILLA AGUDELO JOVANNY PINIL N
PINILLA AGUDELO JOVANNY PINILLA Y
data have;
input Column_A $40. Column_B $20.;
cards;
CAMACHO ANAYA FAIBER ANAYA
EVER ANDRES NAVARRO Navas MELO Navarro Navas
EVER ANDRES NAVARRO MELO Navarro Navas
PINILLA AGUDELO JOVANNY PINIL
PINILLA AGUDELO JOVANNY PINILLA
;
data want;
set have;
flag=ifc(findw(column_a, strip(column_b), ' ', 'i'),'Y','N');
run;
Hi @Kalai2008 This is a pretty good question where FINDW in my opinion best fits the solution. You need a case insensitive search though that is taken care by 'i'
data have;
input Column_A $40. Column_B $20.;
cards;
CAMACHO ANAYA FAIBER ANAYA
EVER ANDRES NAVARRO Navas MELO Navarro Navas
EVER ANDRES NAVARRO MELO Navarro Navas
PINILLA AGUDELO JOVANNY PINIL
PINILLA AGUDELO JOVANNY PINILLA
;
data want;
set have;
flag=ifc(findw(column_a, strip(column_b), ' ', 'i'),'Y','N');
run;
Hi @Kalai2008 This is a pretty good question where FINDW in my opinion best fits the solution. You need a case insensitive search though that is taken care by 'i'
Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.
Register today!Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Select SAS Training centers are offering in-person courses. View upcoming courses for: