Ahh, well looks like @Astounding has already guessed the answer to the main part of your question. When you say %VarType and %VarNum are not macro calls, they in fact are. And in your log before the error message you should have seen: WARNING: Apparent invocation of macro VARTYPE not resolved. That is SAS's way of telling you that you tried to call a macro that doesn't exist. And so it just leaves the macro call there, and that is causing the error for your %IF statement. You can call these functions by nesting them in %SYSFUNC(). Sounds like you might be better off checking to see if the variable is formatted as DATE9, with something like: %if %sysfunc(VARFMT(&dsid.,%sysfunc(VARNUM(&dsid.,&var))))=DATE9. %then %put found a date var!;
... View more