samedi 21 septembre 2019

SAS SQL create table depending on macro variable result

I am struggling with creating a new table in proc sql SAS depending on macro variable result.

1) I want to check if necessary table exists.

2) If it exists then I want to create a new table with given parameters.

3) If it doesn't exist I want to create a new table with different parameters.

I think I know how to check if table exists (0 or 1 in log results):

        %let tex1 = %sysfunc(exist(Base.pk_&monthP1));   
        %put tex1 = &tex1.;

But I do not know how to implement this result into proc sql statement.

I need sth like this:

        proc sql;
        create table test as
        select case when &text1 = 0 then select ...
        else 
        select ...
        end ;
        quit;

Thank you in advance for suggested solutions.

Aucun commentaire:

Enregistrer un commentaire