As said above, many problems with your code.
You need to get up to speed with the macro language, and might want to consider proper training.
In this case, think of the macro language as a code generator.
This will work:
[pre]
%Macro TestsFormat(MyVarIn, MyType, MyValueOk, MyValueNok, MyVarOut);
VAR=input(&MyVarIn ,?? COMMA8.);
if VAR ne . then TYPE='NUM';
else do;
VAR=input(&MyVarIn,?? ANYDTDTM.);
TYPE=ifc( VAR ne . , 'DAT', 'CHAR');
end;
&MyVarOut=ifc(TYPE = &MyType, &MyValueOk, &MyValueNok);
%Mend;
[/pre][pre]
data OUT;
set SASHELP.CLASS;
AGEC=put(age,3.);
%TestsFormat(AGEC, 'NUM', '1','3', code_);
run;
[/pre]
Note that a date like 20091231 will end up as NUM here.