Macro not resolving as expected

31 Views Asked by At

I'm trying to resolve an macro which changes during loop execution since i have defined it inside a single quote it's not getting resolved

%do m = 1 %to 10;

proc sql noprint;
    connect to POSTGRES (&prep_con_str);
    select run_date
        into :m_batch_dt
            from connection to POSTGRES (
                select min(run_date) - INTERVAL '&m. day' as run_date
                    from dummy; 
                                );
    disconnect from POSTGRES;
quit;

%end;

1

There are 1 best solutions below

0
Quentin On

If postgres allows it, change to double quotes.

If not, maybe try macro quoting, e.g.:

%str(%')&m. day%str(%')