I am trying to replace the words from list1 to list2 (basically translating from one language to another), but the search and replace function is not working as expected. It only replaces a portion of thew string and not the complete. Am I doing something incorrect?
Output I am running after running the code above:
names_list names_list_french i
My name is Craig Matthews, My name is Donald Dunn Je m'appis Craig Matthews, Je m'appis Donald Dunn 3
Expected Output:
names_list names_list_french i
My name is Craig Matthews, My name is Donald Dunn Je m'appelle Craig Matthews, Je m'appelle Donald Dunn 3
SAS CODE:
data datatable;
names_list="My name is Craig Matthews, My name is Donald Dunn";
array list1{2} $ _temporary_ (
"My name is Craig Matthews",
"My name is Donald Dunn"
);
array list2{2} $ _temporary_ (
"Je m'appelle Craig Matthews",
"Je m'appelle Donald Dunn"
);
names_list_french=names_list;
put names_list= names_list_french=;
do i=1 to dim(list1);
put list1{i}= list2{i}=;
names_list_french=tranwrd(names_list_french,list1{i},list2{i});
end;
put names_list= names_list_french=;
run;