The logic behind you're macro is wrong.
You are calling that macro inside a datastep, so that macro should contain something (a statement) that could be resolved inside the datastep.
If-else won't be written in macro language but in normal datastep language.
%macro set_istituzionale(set=, varout=);
if &set/100 = 1 then &varout = 'AP';
%mend set_istituzionale;
now if you use your call you will have your datastep resolved this way:
data soff2;
set soff;
%set_istituzionale(set=setcon,varout=set);
run;
will became:
data soff2;
set soff;
if setcon/100 = 1 then set = 'AP';
run;
On your code you were using macro code so your step were resolved internally to the macro boolean statement %if &set/100 resolved were %if setcon/100 where setcon was a string (here we are conditionally speaking with macro language, writing the name of the variable won't catch the value of the variable 'cause it is completelly independent from the datastep).
You should think to macro language only to something that could write down code for you, for example something like your first try could be used to insert a statement conditionally to the value of a macro variable like:
data try;
set want;
%if ¯ovar=A %then %do;
if var1=1 and var2='B' then var3='C';
%end;
%if ¯ovar=B %then %do
if var1=2 and var2='A' then var3='D';
%end;
run;
when the macro variable macrovar will be = A the step will be:
data try;
set want;
if var1=1 and var2='B' then var3='C';
run;
if the macro variable macrovar will be = B the step will be:
data try;
set want;
if var1=2 and var2='A' then var3='D';
run;
But you can use macro code outside from the datastep too, for example to execute a datastep or something else conditionally to the value of a macro variable:
%if ¯ovar=A %then %do;
data try; set tr;
some code;
run;
%end;
%else %if ¯ovar=B %then %do;
proc sort data=tr out=try nodupkey; by var1; run;
%end;