Search code examples
sasconditional-statementssas-macro

How to pass a condition as a macro parameter in SAS


In my macro function I need to pass a condition as a parameter , Can i know how to pass a condition like this in sas

ex : where flag="YES"

%macro counts(con= ,out=);
    proc sort data=ads(&con.) out=teaes_sev nodupkey;
        by usubjid surtypen;
    run;

    proc freq data=teaes_sev noprint;
        tables surtypen/out=teae1_sev;
    run;

    proc transpose data=teae1_sev out=&out.;
        id surtypen;
        var count;
    run;
%mend;

%counts(con=where=(flag ="YES".),out=row1 );

Solution

  • Remove the extraneous period (.) and the code should work

    Change

    %counts(con=where=(flag ="YES".),out=row1 );
    

    to

    %counts(con=where=(flag ="YES"),out=row1 );