Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Macro not correct compiling?

I am creating this SAS macro to simulate the pandas python library, but I am already getting stuck fairly early on.

I will provide my code first and then explain.

%macro testt(database=);

%put ---------------------------------------------------------------;

%put --- Start of %upcase (&sysmacroname) macro;

%put ---;

%put --- Macro parameter values;

%put --- database       =       &database;

%put ---------------------------------------------------------------;

PROC SQL;
    CREATE TABLE &database AS
        SELECT 
                libname
            ,   memname
            ,   nvar
        FROM dictionary.tables
        WHERE libname = '&database';
RUN;
%mend;

%testt(database=DMAZRACT);

In this code I am trying to get each of the tables in a specific libref for further processing, but somehow when it runs. It outputs nothing. The query itself isn’t wrong as when I remove the where statement it works perfectly fine.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

Using %put doesn’t show anything weird about the name either, but I tried %TRIM just incase. However that didn’t really give me a solution either. It must be somewhere in where statement, but I am out of options.

Any help would be appreciated 🙂

>Solution :

Macro variables won’t resolve inside single quotes. Try:

WHERE libname = "&database" ;
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading