Search notes:

SAS statements: do

if … then do … end

do … end; blocks are often used in if statements because the else can only take one statement.
data _null_;

  if 4 > 2 then do; /* start do group */
  
       put "-----------";
       put "-- 4 > 2 --";
       put "-----------";
     
     end;  /* end belongs to do, not to if */
  else do; /* start another do group for else */
  
       put "--------------";
       put "never reached!";
       put "--------------";
  
     end;

run;
Github repository about-SAS, path: /programming/statements/do-block/if-then-do.sas

See also

SAS statements

Index