Search code examples
if-statementsasdatasetexecute

How to conditioning a data step in SAS


I'm inside a big call execute and I have to do a data step only if a flag variable is 0 and not 1. That is, if flag=1 then the data step begin, otherwise not. So I should use IF outside of a macro and outside a data step. How can I fix?

thanks in advance


Solution

  • You need to use macro language, and macro versions of if and then and so on. Try this:

    %let flag = ; 
    
    *or method/logic such as :into or other to set macro value to 1 or 0;
    
    %macro pre_run_check();
        %if &flag = 1 %then %do;
    
        *CODE HERE;
    
        %end;
    %mend;
    
    %pre_run_check();
    

    28/07/2016: czechraisin edited