Skip to content
Advertisement

Use a macro in SAS ‘to_date’ conversion

Being forced to pass my code in explicit pass though, the date conversion no longer works. I would like to use the &aaaa macro in the convert function.

My code example :

I got an error :

“The (full) year must be between -4713 and +9999 and be different from 0”.

Does anyone have a solution?

Advertisement

Answer

Macro variables only resolve in double quotes not single quotes so you’ll have to change that. IIRC Oracle has issues with to_date but you can also provide the dates as : DATE ‘2020-01-01’ but I’d consider making the whole variable, including the quotes your macro variable just to make it a bit easier.

You can modify your original macro variable, aaaa to be in the format below if required. Untested:

User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement