I have a data set that include several paths and the last variable is the frequency of the people following the path.
data path;
input path1 path2 path3 path4 p
You're confusing macro code with data step code.
You need to use if not %if, for one. Also, %eval won't do what you want either. Here's some code with some improvements.
%macro count(name,f,l);
data path;
set me.path;
retain &name;
&name=0;
%do i=1 %to 6;
if path&i=&f and path&i=&l then &name=&name+frequency;
%end;
run;
%mend;
Macro %if is used for comparing the text itself - so it compares path1 to 2, not the value of the path1 variable. To get the value of a variable you have to use regular if. %eval also uses the text, not the variable values, so it will do nothing useful here.
You actually don't need a macro loop for this. Normally we would use arrays. I do assume you want the other parts in macro though...
%macro count(name,f,l);
data path;
set me.path;
retain &name;
array path[6];
&name=0;
do i=1 to 6;
if path[i]=&f and path[i]=&l then &name=&name+frequency;
end;
run;
%mend;
Now, I think this is always 0 still: because it can't be equal to 2 and 5 at the same time. That logic you may need to address.