Hi! I rewrote code for macro without proc sql: %macro symbol_diff_cnt(word1=, word2=);
%let buffer = 0;
%do i=1 %to %sysfunc(max(%length(&word1),%length(&word2)));
%if (%qsubstr(&word1, &i, 1) ^= %qsubstr(&word2, &i, 1)) %then %do;
%let buffer = %eval(&buffer + 1);
%end;
%end;
&buffer;
%mend symbol_diff_cnt; and it works if I call it by strings like that (in this example difference between meanings of word1 and word2 equals 2): data aaa;
input a;
datalines;
1
;run;
%let new = %symbol_diff_cnt(word1='abcdef',word2='adcpef');
%put new = &new;
proc sql;
create table SSS as
select
'abcdef' as s1,
'adcpef' as s2,
&new. as dif
from aaa
;quit; But if I substitute variables, macro compare its names, but not its meanings (in this example difference between names "t1.word" and "t2.word" equals 1): data words;
input word $ n;
datalines;
abcdef 1
adcpef 2
;run;
%let neww = %symbol_diff_cnt(word1=t1.word,word2=t2.word);
%put neww = &neww;
proc sql;
create table TTT as
select
t1.word as slovo1,
t2.word as slovo2,
&neww. as diff
from words(where=(n=1)) t1
left join words(where=(n=2)) t2 on t2.n=t1.n+1
;quit; How can I force macro to compare meanings of variables, not its names?
... View more