Javi:
Another point to add to Lawrence's answer is that if a macro variable has no value, when substitution is done, you could consider it to be the same as adding a blank or hit on the space bar to your code.
The first time this Proc Sort is invoked, there is no value for var3 (%let var3=;) so the data is only sorted by region and subsidiary. For the second Proc Sort, all 3 macro variables have a value, so the data is sorted by all 3 variables.
cynthia
[pre]
options mprint mlogic symbolgen;
%let var1 = region;
%let var2 = subsidiary;
%let var3 =;
proc sort data=sashelp.shoes out=shoes1;
by &var1 &var2 &var3;
run;
options mprint mlogic symbolgen;
%let var1 = product;
%let var2 = region;
%let var3 =subsidiary;
proc sort data=sashelp.shoes out=shoes2;
by &var1 &var2 &var3;
run;
[/pre]